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:
+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
+20
-10
@@ -1,6 +1,7 @@
|
||||
package com.cf.imes.module.manage.controller.admin.plate;
|
||||
|
||||
import com.cf.imes.module.manage.controller.admin.plate.vo.plate.*;
|
||||
import com.cf.imes.module.manage.service.plate.PlateExcelUtil;
|
||||
import io.swagger.v3.oas.annotations.Parameters;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
@@ -9,7 +10,6 @@ import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.*;
|
||||
import java.io.IOException;
|
||||
|
||||
@@ -98,16 +98,17 @@ public class PlateController {
|
||||
|
||||
@GetMapping("/get-import-template")
|
||||
@Operation(summary = "获得导入用户模板")
|
||||
@PreAuthorize("@ss.hasPermission('manage:plate:export')")
|
||||
public void importTemplate(HttpServletResponse response) throws IOException {
|
||||
// 手动创建导出 demo
|
||||
List<PlateImportExcelVO> list = Arrays.asList(
|
||||
PlateImportExcelVO.builder().goodsId("SP1123456").goodsName("xixih").material("颗粒板").width(BigDecimal.valueOf(1212.3)).height(BigDecimal.valueOf(12131.6))
|
||||
.thickness(BigDecimal.valueOf(0.2)).brand("SexEnum.MALE.getSex()").spec("大厂").remark("测试").build(),//.price(33333.2)
|
||||
PlateImportExcelVO.builder().goodsId("SP1123457").goodsName("2L").material("yuanma@cf.com").width(BigDecimal.valueOf(21.6)).height(BigDecimal.valueOf(123231.6))
|
||||
.thickness(BigDecimal.valueOf(5.3)).brand("kkkkkk").spec("大厂").remark("测试").build()//.price(333.555)
|
||||
PlateImportExcelVO.builder().goodsId("SP1123456").goodsName("xixih").material("颗粒板").width(String.valueOf(1212.3)).height(String.valueOf(12131.6))
|
||||
.thickness(String.valueOf(0.2)).brand("鹅厂").spec("大厂").remark("测试").price(String.valueOf(33333.2)).build(),
|
||||
PlateImportExcelVO.builder().goodsId("SP1123457").goodsName("2L").material("yuanma@cf.com").width(String.valueOf(21.6)).height(String.valueOf(12231.6))
|
||||
.thickness(String.valueOf(5.3)).brand("kkkkkk").spec("大厂").remark("测试").price(String.valueOf(333.555)).build()
|
||||
);
|
||||
// 输出
|
||||
ExcelUtils.write(response, "板材导入模板.xls", "板材列表", PlateImportExcelVO.class, list);
|
||||
ExcelUtils.write(response, "板材导入模板.xlsx", "板材列表", PlateImportExcelVO.class, list);
|
||||
}
|
||||
|
||||
@PostMapping("/import")
|
||||
@@ -118,11 +119,20 @@ public class PlateController {
|
||||
@Parameter(name = "organId", description = "板材所属组织ID")
|
||||
})
|
||||
@PreAuthorize("@ss.hasPermission('manage:plate:import')")
|
||||
public CommonResult<PlateImportRespVO> importExcel(@RequestParam("file") MultipartFile file,
|
||||
public void importExcel(@RequestParam("file") MultipartFile file,
|
||||
@RequestParam(value = "updateSupport", required = false, defaultValue = "false") Boolean updateSupport,
|
||||
@RequestParam(value = "organId") Long organId) throws Exception {
|
||||
List<PlateImportExcelVO> list = ExcelUtils.read(file, PlateImportExcelVO.class);
|
||||
return success(plateService.importPlateList(list, updateSupport , organId));
|
||||
@RequestParam(value = "organId") Long organId,
|
||||
HttpServletResponse response) throws Exception {
|
||||
PlateExcelUtil plateExcelUtil = new PlateExcelUtil();
|
||||
List<PlateImportExcelVO> list = plateExcelUtil.read(file, PlateImportExcelVO.class);
|
||||
|
||||
// 判断文件是否导入成功
|
||||
if (!plateExcelUtil.getFlag())
|
||||
ExcelUtils.write(response, "板材导入模板.xlsx", "板材列表", PlateImportExcelVO.class, list);
|
||||
else
|
||||
plateService.importPlateList(list, updateSupport, organId);// 成功,批量导入
|
||||
|
||||
plateExcelUtil.clear();
|
||||
}
|
||||
|
||||
}
|
||||
+51
-11
@@ -1,18 +1,14 @@
|
||||
package com.cf.imes.module.manage.controller.admin.plate.vo.plate;
|
||||
|
||||
import com.cf.imes.framework.excel.core.annotations.DictFormat;
|
||||
import com.cf.imes.framework.excel.core.convert.DictConvert;
|
||||
import com.cf.imes.module.system.enums.DictTypeConstants;
|
||||
import com.alibaba.excel.annotation.ExcelProperty;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
|
||||
/**
|
||||
* 用户 Excel 导入 VO
|
||||
@@ -25,36 +21,80 @@ import java.time.LocalDateTime;
|
||||
public class PlateImportExcelVO {
|
||||
|
||||
@ExcelProperty("商品编号")
|
||||
@NotEmpty(message = "商品编号不能为空")
|
||||
private String goodsId;
|
||||
|
||||
@ExcelProperty("商品名称")
|
||||
@NotEmpty(message = "商品名称不能为空")
|
||||
private String goodsName;
|
||||
|
||||
@ExcelProperty("材质")
|
||||
@NotEmpty(message = "材质不能为空")
|
||||
private String material;
|
||||
|
||||
@ExcelProperty("颜色")
|
||||
@NotEmpty(message = "颜色不能为空")
|
||||
private String color;
|
||||
|
||||
@ExcelProperty("宽度")
|
||||
private BigDecimal width;
|
||||
@NotEmpty(message = "宽度不能为空")
|
||||
private String width;
|
||||
|
||||
@ExcelProperty("高度")
|
||||
private BigDecimal height;
|
||||
@ExcelProperty("高度")// float(8,3)
|
||||
@NotEmpty(message = "高度不能为空")
|
||||
private String height;
|
||||
|
||||
@ExcelProperty("厚度")
|
||||
private BigDecimal thickness;
|
||||
@NotEmpty(message = "厚度不能为空")
|
||||
private String thickness;
|
||||
|
||||
@ExcelProperty("价格")
|
||||
private Double price;
|
||||
@NotEmpty(message = "价格不能为空")
|
||||
private String price;
|
||||
|
||||
@ExcelProperty("品牌")
|
||||
@NotEmpty(message = "品牌不能为空")
|
||||
private String brand;
|
||||
|
||||
@ExcelProperty("规格")
|
||||
@NotEmpty(message = "规格不能为空")
|
||||
private String spec;
|
||||
|
||||
@ExcelProperty("备注")
|
||||
private String remark;
|
||||
|
||||
@ExcelProperty("上传结果")
|
||||
private String result;
|
||||
|
||||
public boolean isValidGoods() {
|
||||
return !(goodsId == null || goodsId.isEmpty() || goodsName == null || goodsName.isEmpty() || material == null ||
|
||||
material.isEmpty() || color == null || color.isEmpty() || width == null ||width.isEmpty() || height == null ||
|
||||
height.isEmpty() || height == null ||thickness.isEmpty() || brand == null || brand.isEmpty() || spec == null || spec.isEmpty());
|
||||
}
|
||||
|
||||
// 数据长度判断
|
||||
public boolean checkPrecision(Double number) {
|
||||
if (number == null) {
|
||||
return false;
|
||||
}
|
||||
// 将浮点数转换成字符串
|
||||
String numberStr = Double.toString(number);
|
||||
|
||||
// 分割整数部分和小数部分
|
||||
String[] parts = numberStr.split("\\.");
|
||||
String integerPart = parts[0];
|
||||
String decimalPart = parts.length > 1 ? parts[1] : "";
|
||||
|
||||
// 检查整数部分位数
|
||||
if (integerPart.length() > 5) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// 检查小数部分位数
|
||||
if (decimalPart.length() > 3) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
+3
-5
@@ -2,8 +2,6 @@ package com.cf.imes.module.manage.controller.admin.plate.vo.plate;
|
||||
|
||||
import lombok.*;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.*;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import com.cf.imes.framework.common.pojo.PageParam;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
@@ -30,13 +28,13 @@ public class PlatePageReqVO extends PageParam {
|
||||
private String color;
|
||||
|
||||
@Schema(description = "宽度")
|
||||
private BigDecimal width;
|
||||
private Double width;
|
||||
|
||||
@Schema(description = "高度")
|
||||
private BigDecimal height;
|
||||
private Double height;
|
||||
|
||||
@Schema(description = "厚度")
|
||||
private BigDecimal thickness;
|
||||
private Double thickness;
|
||||
|
||||
@Schema(description = "价格", example = "3380")
|
||||
private Double price;
|
||||
|
||||
+5
-10
@@ -3,10 +3,6 @@ package com.cf.imes.module.manage.controller.admin.plate.vo.plate;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.*;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.*;
|
||||
import java.util.*;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
import java.time.LocalDateTime;
|
||||
import com.alibaba.excel.annotation.*;
|
||||
|
||||
@@ -16,11 +12,10 @@ import com.alibaba.excel.annotation.*;
|
||||
public class PlateRespVO {
|
||||
|
||||
@Schema(description = "主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
||||
@ExcelProperty("主键")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "客户的商品编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
||||
@ExcelProperty("客户的商品编号")
|
||||
@ExcelProperty("商品编号")
|
||||
private String goodsId;
|
||||
|
||||
@Schema(description = "商品名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "赵六")
|
||||
@@ -28,7 +23,7 @@ public class PlateRespVO {
|
||||
private String goodsName;
|
||||
|
||||
@Schema(description = "材质:颗粒板、欧松板、多层板、生态板、禾香板、密度板、实木、铝蜂窝板、铝塑板", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@ExcelProperty("材质:颗粒板、欧松板、多层板、生态板、禾香板、密度板、实木、铝蜂窝板、铝塑板")
|
||||
@ExcelProperty("材质")
|
||||
private String material;
|
||||
|
||||
@Schema(description = "颜色", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@@ -37,15 +32,15 @@ public class PlateRespVO {
|
||||
|
||||
@Schema(description = "宽度", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@ExcelProperty("宽度")
|
||||
private BigDecimal width;
|
||||
private Double width;
|
||||
|
||||
@Schema(description = "高度", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@ExcelProperty("高度")
|
||||
private BigDecimal height;
|
||||
private Double height;
|
||||
|
||||
@Schema(description = "厚度", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@ExcelProperty("厚度")
|
||||
private BigDecimal thickness;
|
||||
private Double thickness;
|
||||
|
||||
@Schema(description = "价格", requiredMode = Schema.RequiredMode.REQUIRED, example = "3380")
|
||||
@ExcelProperty("价格")
|
||||
|
||||
+3
-4
@@ -4,7 +4,6 @@ import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.*;
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.math.BigDecimal;
|
||||
|
||||
@Schema(description = "管理后台 - 板材信息表 plate_{N}新增/修改 Request VO")
|
||||
@Data
|
||||
@@ -31,15 +30,15 @@ public class PlateSaveReqVO {
|
||||
|
||||
@Schema(description = "宽度", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotNull(message = "宽度不能为空")
|
||||
private BigDecimal width;
|
||||
private Double width;
|
||||
|
||||
@Schema(description = "高度", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotNull(message = "高度不能为空")
|
||||
private BigDecimal height;
|
||||
private Double height;
|
||||
|
||||
@Schema(description = "厚度", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotNull(message = "厚度不能为空")
|
||||
private BigDecimal thickness;
|
||||
private Double thickness;
|
||||
|
||||
@Schema(description = "价格", requiredMode = Schema.RequiredMode.REQUIRED, example = "3380")
|
||||
@NotNull(message = "价格不能为空")
|
||||
|
||||
+3
-7
@@ -2,10 +2,6 @@ package com.cf.imes.module.manage.dal.dataobject.plate;
|
||||
|
||||
import lombok.*;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.*;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.LocalDateTime;
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import com.cf.imes.framework.mybatis.core.dataobject.BaseDO;
|
||||
|
||||
@@ -48,15 +44,15 @@ public class PlateDO extends BaseDO {
|
||||
/**
|
||||
* 宽度
|
||||
*/
|
||||
private BigDecimal width;
|
||||
private Double width;
|
||||
/**
|
||||
* 高度
|
||||
*/
|
||||
private BigDecimal height;
|
||||
private Double height;
|
||||
/**
|
||||
* 厚度
|
||||
*/
|
||||
private BigDecimal thickness;
|
||||
private Double thickness;
|
||||
/**
|
||||
* 价格
|
||||
*/
|
||||
|
||||
+3
-1
@@ -6,6 +6,7 @@ import com.cf.imes.framework.mybatis.core.mapper.BaseMapperX;
|
||||
import com.cf.imes.module.manage.controller.admin.plate.vo.plate.PlatePageReqVO;
|
||||
import com.cf.imes.module.manage.dal.dataobject.plate.PlateDO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
/**
|
||||
* 板材信息表 plate_{N} Mapper
|
||||
@@ -37,4 +38,5 @@ public interface PlateMapper extends BaseMapperX<PlateDO> {
|
||||
.orderByDesc(PlateDO::getId));
|
||||
}
|
||||
|
||||
}
|
||||
PlateDO selectOneById(@Param("id") Long id, @Param("organId") Long organId);
|
||||
}
|
||||
|
||||
+102
@@ -0,0 +1,102 @@
|
||||
package com.cf.imes.module.manage.service.plate;
|
||||
|
||||
import com.alibaba.excel.context.AnalysisContext;
|
||||
import com.alibaba.excel.event.AnalysisEventListener;
|
||||
import com.cf.imes.module.manage.controller.admin.plate.vo.plate.PlateImportExcelVO;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
@Slf4j
|
||||
public final class PlateExcelListener<T> extends AnalysisEventListener<PlateImportExcelVO> {
|
||||
|
||||
/**
|
||||
* 自定义用于暂时存储data
|
||||
* 可以通过实例获取该值
|
||||
*/
|
||||
private List<PlateImportExcelVO> datas = new ArrayList<>();
|
||||
|
||||
private boolean flag = true;
|
||||
|
||||
private Map<Integer, String> valueMap = new HashMap<>();
|
||||
|
||||
/**
|
||||
* 每解析一行都会回调invoke()方法
|
||||
*
|
||||
* @param data 读取后的数据对象
|
||||
* @param context 内容
|
||||
*/
|
||||
@Override
|
||||
public void invoke(PlateImportExcelVO data, AnalysisContext context) {
|
||||
if (!data.isValidGoods()) {//返回false,表示商品信息无效;否则返回true,表示商品信息有效
|
||||
data.setResult("商品关键信息缺少");
|
||||
this.flag = false;
|
||||
}
|
||||
checkData(data.getHeight(),"高度",data);
|
||||
checkData(data.getWidth(),"宽度",data);
|
||||
checkData(data.getThickness(),"厚度",data);
|
||||
checkData(data.getPrice(),"价格",data);
|
||||
if (data.getResult() != null)
|
||||
data.setResult(data.getResult().replace("null,", ""));
|
||||
valueMap.put(context.getCurrentRowNum(), data.getResult());
|
||||
datas.add(data);
|
||||
}
|
||||
|
||||
// 错误判断
|
||||
private void checkData(String valueCheck, String head, PlateImportExcelVO data) {
|
||||
// 长宽厚、价格判断非空
|
||||
if (valueCheck == null || valueCheck.equals("")) {
|
||||
this.flag = false;
|
||||
data.setResult(data.getResult() + "," + head + "信息缺少");
|
||||
} else {
|
||||
try {
|
||||
if (!data.checkPrecision(Double.valueOf(valueCheck))) {
|
||||
data.setResult(data.getResult() + "," + head + "数据有误");
|
||||
this.flag = false;
|
||||
}
|
||||
} catch (NumberFormatException e) {
|
||||
this.flag = false;
|
||||
data.setResult(data.getResult() + "," + head + "需要填写数字");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 读取完后操作
|
||||
*
|
||||
* @param context
|
||||
*/
|
||||
@Override
|
||||
public void doAfterAllAnalysed(AnalysisContext context) {
|
||||
if (this.flag)
|
||||
log.info("PlateExcelListener 所有数据读取完成");
|
||||
}
|
||||
|
||||
/**
|
||||
* 返回数据
|
||||
*
|
||||
* @return 返回读取的数据集合
|
||||
**/
|
||||
public List<PlateImportExcelVO> getDatas() {
|
||||
return datas;
|
||||
}
|
||||
|
||||
/**
|
||||
* 返回读取结果
|
||||
*
|
||||
* @return 是否读取成功
|
||||
**/
|
||||
public boolean getFlag() {
|
||||
return flag;
|
||||
}
|
||||
|
||||
/**
|
||||
* 返回错误信息
|
||||
*
|
||||
* @return String
|
||||
**/
|
||||
public Map<Integer, String> getValueMap() {
|
||||
return valueMap;
|
||||
}
|
||||
|
||||
}
|
||||
+64
@@ -0,0 +1,64 @@
|
||||
package com.cf.imes.module.manage.service.plate;
|
||||
|
||||
import com.alibaba.excel.EasyExcel;
|
||||
import com.alibaba.excel.ExcelWriter;
|
||||
import com.alibaba.excel.write.metadata.WriteSheet;
|
||||
import com.cf.imes.module.manage.controller.admin.plate.vo.plate.PlateImportExcelVO;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.poi.ss.formula.functions.T;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Slf4j
|
||||
public class PlateExcelUtil {
|
||||
|
||||
private String value;
|
||||
|
||||
private PlateExcelListener<PlateImportExcelVO> excelListener = new PlateExcelListener<>();
|
||||
|
||||
public List<PlateImportExcelVO> read(MultipartFile file, Class<PlateImportExcelVO> head) throws IOException {
|
||||
|
||||
if (file.isEmpty()) {
|
||||
value = "文件为空";
|
||||
throw new IOException("文件为空");
|
||||
} else if (!(file.getOriginalFilename().endsWith(".xlsx") || file.getOriginalFilename().endsWith(".xls"))) {
|
||||
value = "文件格式不正确";
|
||||
throw new IOException("文件格式不正确");
|
||||
} else if (file.getSize() > 1024 * 1024 * 10) {
|
||||
value = "文件大小超过 10M";
|
||||
throw new IOException("文件大小超过 10M");
|
||||
} else if (file.getSize() == 0) {
|
||||
value = "文件大小为 0";
|
||||
throw new IOException("文件大小为 0");
|
||||
} else {
|
||||
EasyExcel.read(file.getInputStream(), PlateImportExcelVO.class, excelListener)
|
||||
.autoCloseStream(true) // 不要自动关闭,交给 Servlet 自己处理
|
||||
.headRowNumber(1).sheet(0).doRead();
|
||||
//获取读取的数据
|
||||
List<PlateImportExcelVO> list = excelListener.getDatas();
|
||||
|
||||
if (excelListener.getValueMap().size() > 0)
|
||||
excelListener.getValueMap().forEach((k, v) -> {
|
||||
list.get(k - 1).setResult(v);
|
||||
});
|
||||
return list;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean getFlag() {
|
||||
return excelListener.getFlag();
|
||||
}
|
||||
|
||||
public void clear() {
|
||||
excelListener.getDatas().clear();
|
||||
}
|
||||
|
||||
public Map<Integer, String> getValueMap() {
|
||||
return excelListener.getValueMap();
|
||||
}
|
||||
}
|
||||
+20
-22
@@ -4,6 +4,7 @@ import cn.hutool.core.collection.CollUtil;
|
||||
import com.cf.imes.framework.common.exception.ServiceException;
|
||||
import com.cf.imes.framework.common.exception.util.ServiceExceptionUtil;
|
||||
import com.cf.imes.framework.common.pojo.CommonResult;
|
||||
import com.cf.imes.framework.organ.core.context.OrganContextHolder;
|
||||
import com.cf.imes.module.manage.controller.admin.plate.vo.plate.PlateImportExcelVO;
|
||||
import com.cf.imes.module.manage.controller.admin.plate.vo.plate.PlateImportRespVO;
|
||||
import com.cf.imes.module.manage.controller.admin.plate.vo.plate.PlatePageReqVO;
|
||||
@@ -17,7 +18,6 @@ import org.springframework.transaction.annotation.Transactional;
|
||||
import java.util.*;
|
||||
|
||||
import com.cf.imes.module.manage.dal.dataobject.plate.PlateDO;
|
||||
import com.cf.imes.framework.datapermission.core.util.DataPermissionUtils;
|
||||
import com.cf.imes.framework.common.pojo.PageResult;
|
||||
import com.cf.imes.framework.common.util.object.BeanUtils;
|
||||
|
||||
@@ -51,7 +51,7 @@ public class PlateServiceImpl implements PlateService {
|
||||
validateGoodExists(createReqVO.getGoodsId(), createReqVO.getOrganId());
|
||||
plate.setOrganId(createReqVO.getOrganId());
|
||||
}
|
||||
plateMapper.insert(plate);
|
||||
plateMapper.insert(plate.setOrganId(OrganContextHolder.getOrganId()));// 组织id未传输
|
||||
// 返回
|
||||
return plate.getId();
|
||||
}
|
||||
@@ -90,13 +90,6 @@ public class PlateServiceImpl implements PlateService {
|
||||
}
|
||||
|
||||
|
||||
private void validatePlateForCreateOrUpdate(PlateImportExcelVO importPlate) {
|
||||
// 关闭数据权限,避免因为没有数据权限,查询不到数据,进而导致唯一校验不正确
|
||||
DataPermissionUtils.executeIgnore(() -> {
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class) // 添加事务,异常则回滚所有导入
|
||||
public PlateImportRespVO importPlateList(List<PlateImportExcelVO> importPlates, boolean isUpdateSupport , Long organId) {
|
||||
@@ -106,19 +99,17 @@ public class PlateServiceImpl implements PlateService {
|
||||
validateOrganExists(organId);
|
||||
PlateImportRespVO respVO = PlateImportRespVO.builder().createPlateNames(new ArrayList<>())
|
||||
.updatePlateNames(new ArrayList<>()).failurePlateNames(new LinkedHashMap<>()).build();
|
||||
// 批量插入集合
|
||||
List<PlateDO> insertList = new ArrayList<>();
|
||||
// 批量更新集合
|
||||
List<PlateDO> updateList = new ArrayList<>();
|
||||
importPlates.forEach(importPlate -> {
|
||||
// 校验,判断是否有不符合的原因 校验全部是否为空
|
||||
try {
|
||||
validatePlateForCreateOrUpdate(importPlate);
|
||||
} catch (ServiceException ex) {
|
||||
respVO.getFailurePlateNames().put(importPlate.getGoodsName() , ex.getMessage());
|
||||
return;
|
||||
}
|
||||
// 判断如果不存在,在进行插入
|
||||
PlateDO existPlate = plateMapper.selectByGoodID(importPlate.getGoodsId(), organId);
|
||||
if (existPlate == null) {
|
||||
plateMapper.insert(BeanUtils.toBean(importPlate, PlateDO.class));
|
||||
respVO.getCreatePlateNames().add(importPlate.getGoodsName());
|
||||
insertList.add(BeanUtils.toBean(importPlate, PlateDO.class).setOrganId(organId));
|
||||
// plateMapper.insert(BeanUtils.toBean(importPlate, PlateDO.class).setOrganId(organId));
|
||||
// respVO.getCreatePlateNames().add(importPlate.getGoodsName());
|
||||
return;
|
||||
}
|
||||
// 如果存在,判断是否允许更新
|
||||
@@ -126,11 +117,18 @@ public class PlateServiceImpl implements PlateService {
|
||||
respVO.getFailurePlateNames().put(importPlate.getGoodsName(), ErrorCodeConstants.PLATE_EXISTS.getMsg());
|
||||
return;
|
||||
}
|
||||
PlateDO plateDO = BeanUtils.toBean(importPlate, PlateDO.class);
|
||||
plateDO.setId(existPlate.getId());
|
||||
plateMapper.updateById(plateDO);
|
||||
respVO.getUpdatePlateNames().add(importPlate.getGoodsName());
|
||||
PlateDO plateDO = BeanUtils.toBean(importPlate, PlateDO.class).setOrganId(organId).setId(existPlate.getId());
|
||||
updateList.add(plateDO);
|
||||
// plateMapper.updateById(plateDO);
|
||||
// respVO.getUpdatePlateNames().add(importPlate.getGoodsName());
|
||||
});
|
||||
// 批量插入,批量更新
|
||||
if (insertList.size() > 0 && insertList != null) {
|
||||
plateMapper.insertBatch(insertList);
|
||||
}
|
||||
if (updateList.size() > 0 && updateList != null) {
|
||||
plateMapper.updateBatch(updateList);
|
||||
}
|
||||
return respVO;
|
||||
}
|
||||
|
||||
|
||||
+29
@@ -0,0 +1,29 @@
|
||||
<?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.manage.dal.mysql.plate.PlateMapper">
|
||||
|
||||
<select id="selectOneById" resultType="com.cf.imes.module.manage.dal.dataobject.plate.PlateDO">
|
||||
SELECT
|
||||
id,
|
||||
goods_id,
|
||||
organ_id,
|
||||
goods_name,
|
||||
material,
|
||||
color,
|
||||
width,
|
||||
height,
|
||||
thickness,
|
||||
brand,
|
||||
spec,
|
||||
remark,
|
||||
creator,
|
||||
create_time,
|
||||
updater,
|
||||
update_time,
|
||||
deleted,
|
||||
price
|
||||
FROM
|
||||
plate
|
||||
where organ_id = #{organId} and id = #{id} and deleted = 0
|
||||
</select>
|
||||
</mapper>
|
||||
+4
-2
@@ -37,7 +37,9 @@ public interface ErrorCodeConstants {
|
||||
ErrorCode USER_USERNAME_EXISTS = new ErrorCode(1_002_003_000, "用户账号已经存在");
|
||||
ErrorCode USER_MOBILE_EXISTS = new ErrorCode(1_002_003_001, "手机号已经存在");
|
||||
ErrorCode USER_EMAIL_EXISTS = new ErrorCode(1_002_003_002, "邮箱已经存在");
|
||||
ErrorCode USER_NOT_EXISTS = new ErrorCode(1_002_003_003, "用户不存在");
|
||||
ErrorCode
|
||||
|
||||
USER_NOT_EXISTS = new ErrorCode(1_002_003_003, "用户不存在");
|
||||
ErrorCode USER_IMPORT_LIST_IS_EMPTY = new ErrorCode(1_002_003_004, "导入用户数据不能为空!");
|
||||
ErrorCode USER_PASSWORD_FAILED = new ErrorCode(1_002_003_005, "用户密码校验失败");
|
||||
ErrorCode USER_IS_DISABLE = new ErrorCode(1_002_003_006, "名字为【{}】的用户已被禁用");
|
||||
@@ -175,7 +177,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不存在");
|
||||
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, "工序组不存在");
|
||||
|
||||
+21
-9
@@ -5,6 +5,7 @@ import javax.validation.Valid;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
|
||||
import com.cf.imes.module.system.controller.admin.process.vo.group.ProcessGroupRespVO;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
@@ -74,12 +75,30 @@ public class ProcessController {
|
||||
return success(BeanUtils.toBean(processUser, ProcessUserRespVO.class));
|
||||
}
|
||||
|
||||
@GetMapping("/allGet")
|
||||
@Operation(summary = "获得工序全部信息")
|
||||
@PreAuthorize("@ss.hasPermission('system:process:query')")
|
||||
public CommonResult<PageResult<ProcessDO>> getProcessAll(@Valid ProcessPageReqVO pageReqVO) {
|
||||
pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
|
||||
PageResult<ProcessDO> pageResult = processService.getProcessPage(pageReqVO);
|
||||
return success(BeanUtils.toBean(pageResult, ProcessDO.class));
|
||||
}
|
||||
|
||||
@GetMapping("/getAll")
|
||||
@Operation(summary = "获得所有工序信息")
|
||||
@PreAuthorize("@ss.hasPermission('system:process:query')")
|
||||
public CommonResult<List<ProcessDO>> getAllProcess() {
|
||||
List<ProcessDO> processUser = processService.getAllProcess();
|
||||
return success(BeanUtils.toBean(processUser, ProcessDO.class));
|
||||
}
|
||||
|
||||
|
||||
@GetMapping("/page")
|
||||
@Operation(summary = "获得工序信息分页")
|
||||
@PreAuthorize("@ss.hasPermission('system:process:query')")
|
||||
public CommonResult<PageResult<ProcessRespVO>> getProcessPage(@Valid ProcessPageReqVO pageReqVO) {
|
||||
PageResult<ProcessRespVO> pageResult = processService.getProcessPageAll(pageReqVO);
|
||||
return success(pageResult);
|
||||
return success(BeanUtils.toBean(pageResult, ProcessRespVO.class));
|
||||
}
|
||||
|
||||
@GetMapping("/export-excel")
|
||||
@@ -91,15 +110,8 @@ public class ProcessController {
|
||||
pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
|
||||
List<ProcessDO> list = processService.getProcessPage(pageReqVO).getList();
|
||||
// 导出 Excel
|
||||
ExcelUtils.write(response, "工序信息表 process.xls", "数据", ProcessRespVO.class,
|
||||
ExcelUtils.write(response, "工序信息表.xls", "数据", ProcessRespVO.class,
|
||||
BeanUtils.toBean(list, ProcessRespVO.class));
|
||||
}
|
||||
|
||||
@GetMapping("/getAll")
|
||||
@Operation(summary = "获得所有工序信息")
|
||||
@PreAuthorize("@ss.hasPermission('system:process:query')")
|
||||
public CommonResult<List<ProcessDO>> getAllProcess() {
|
||||
List<ProcessDO> processUser = processService.getAllProcess();
|
||||
return success(BeanUtils.toBean(processUser, ProcessDO.class));
|
||||
}
|
||||
}
|
||||
+2
-1
@@ -52,6 +52,7 @@ public class ProcessGroupController {
|
||||
|
||||
@PostMapping("/create")
|
||||
@Operation(summary = "创建工序组")
|
||||
@PreAuthorize("@ss.hasPermission('system:process-group:create')")
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public CommonResult<Long> createProcessGroup(@Valid @RequestBody ProcessGroupSaveReqVO createReqVOLists) {
|
||||
return success(processGroupService.createProcessGroup(createReqVOLists));
|
||||
@@ -92,7 +93,7 @@ public class ProcessGroupController {
|
||||
}
|
||||
|
||||
@GetMapping("/export-excel")
|
||||
@Operation(summary = "导出工序组表 process_group Excel")
|
||||
@Operation(summary = "导出工序组表")
|
||||
@PreAuthorize("@ss.hasPermission('system:process-group:export')")
|
||||
@OperateLog(type = EXPORT)
|
||||
public void exportProcessGroupExcel(@Valid ProcessGroupPageReqVO pageReqVO,
|
||||
|
||||
+3
@@ -14,6 +14,9 @@ import static com.cf.imes.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH
|
||||
@ToString(callSuper = true)
|
||||
public class ProcessGroupPageReqVO extends PageParam {
|
||||
|
||||
@Schema(description = "组织id", example = "1")
|
||||
private Long organId;
|
||||
|
||||
@Schema(description = "工序组名称", example = "赵六")
|
||||
private String name;
|
||||
|
||||
|
||||
+3
-2
@@ -59,10 +59,11 @@ public class ProcessUserSaveReqVO {
|
||||
private Double prepareTime;
|
||||
|
||||
@Schema(description = "描述", requiredMode = Schema.RequiredMode.REQUIRED, example = "你说的对")
|
||||
@NotEmpty(message = "描述不能为空")
|
||||
private String description;
|
||||
|
||||
@Schema(description = "用户ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "12,13")
|
||||
private String Users;
|
||||
private String users;
|
||||
|
||||
@Schema(description = "组织Id", requiredMode = Schema.RequiredMode.REQUIRED, example = "181")
|
||||
private Long organId;
|
||||
}
|
||||
|
||||
+1
@@ -16,4 +16,5 @@ public class ProcessAndUserSaveReqVO {
|
||||
@NotNull(message = "用户 ID不能为空")
|
||||
private Long userId;
|
||||
|
||||
private Long organId;
|
||||
}
|
||||
+4
@@ -76,4 +76,8 @@ public class ProcessDO extends BaseDO {
|
||||
*/
|
||||
private String description;
|
||||
|
||||
/**
|
||||
* 组织id
|
||||
*/
|
||||
private Long organId;
|
||||
}
|
||||
+4
@@ -24,6 +24,10 @@ public class ProcessGroupDO extends BaseDO {
|
||||
*/
|
||||
@TableId
|
||||
private Long id;
|
||||
/**
|
||||
* 组织id
|
||||
*/
|
||||
private Long organId;
|
||||
/**
|
||||
* 工序组名称
|
||||
*/
|
||||
|
||||
-40
@@ -1,40 +0,0 @@
|
||||
package com.cf.imes.module.system.dal.dataobject.process;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.cf.imes.framework.mybatis.core.dataobject.BaseDO;
|
||||
import com.cf.imes.module.system.controller.admin.process.vo.process.ProcessRespVO;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @projectName: cf_imes_back
|
||||
* @author: 晨丰科技
|
||||
* @date: 2024/2/27 11:48
|
||||
*/
|
||||
public class ProcessGroupListDO extends BaseDO {
|
||||
/**
|
||||
* 工序组 ID
|
||||
*/
|
||||
@TableId
|
||||
private Long id;
|
||||
/**
|
||||
* 工序组名称
|
||||
*/
|
||||
private String name;
|
||||
/**
|
||||
* 是否默认工序组:0 否 1 是
|
||||
*/
|
||||
private Boolean isDefault;
|
||||
/**
|
||||
* 排序优先级
|
||||
*/
|
||||
private Short sort;
|
||||
/**
|
||||
* 明细,工序信息
|
||||
*/
|
||||
private List<ProcessDO> lists;
|
||||
/**
|
||||
* 描述
|
||||
*/
|
||||
private String description;
|
||||
}
|
||||
+4
@@ -20,6 +20,10 @@ import com.cf.imes.framework.mybatis.core.dataobject.BaseDO;
|
||||
@AllArgsConstructor
|
||||
public class ProcessUserDO {
|
||||
|
||||
/**
|
||||
* 组织 ID
|
||||
*/
|
||||
private Long organId;
|
||||
/**
|
||||
* 工序 ID
|
||||
*/
|
||||
|
||||
+4
@@ -4,8 +4,10 @@ import com.cf.imes.framework.common.pojo.PageResult;
|
||||
import com.cf.imes.framework.mybatis.core.mapper.BaseMapperX;
|
||||
import com.cf.imes.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||
import com.cf.imes.module.system.controller.admin.process.vo.group.ProcessGroupPageReqVO;
|
||||
import com.cf.imes.module.system.dal.dataobject.process.ProcessDO;
|
||||
import com.cf.imes.module.system.dal.dataobject.process.ProcessGroupDO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
/**
|
||||
* 工序组表 process_group Mapper
|
||||
@@ -21,9 +23,11 @@ public interface ProcessGroupMapper extends BaseMapperX<ProcessGroupDO> {
|
||||
.eqIfPresent(ProcessGroupDO::getIsDefault, reqVO.getIsDefault())
|
||||
.eqIfPresent(ProcessGroupDO::getSort, reqVO.getSort())
|
||||
.eqIfPresent(ProcessGroupDO::getItems, reqVO.getItems())
|
||||
.eqIfPresent(ProcessGroupDO::getOrganId, reqVO.getOrganId())
|
||||
.eqIfPresent(ProcessGroupDO::getDescription, reqVO.getDescription())
|
||||
.betweenIfPresent(ProcessGroupDO::getCreateTime, reqVO.getCreateTime())
|
||||
.orderByDesc(ProcessGroupDO::getId));
|
||||
}
|
||||
|
||||
ProcessDO selectOneById(@Param("id") Long id, @Param("organId") Long organId);
|
||||
}
|
||||
+3
@@ -30,6 +30,7 @@ public interface ProcessMapper extends BaseMapperX<ProcessDO> {
|
||||
.eqIfPresent(ProcessDO::getSort, reqVO.getSort())
|
||||
.eqIfPresent(ProcessDO::getHourCapacity, reqVO.getHourCapacity())
|
||||
.eqIfPresent(ProcessDO::getUnit, reqVO.getUnit())
|
||||
.eqIfPresent(ProcessDO::getOrganId, reqVO.getOrganId())
|
||||
.eqIfPresent(ProcessDO::getIsEnabled, reqVO.getIsEnabled())
|
||||
.betweenIfPresent(ProcessDO::getPrepareTime, reqVO.getPrepareTime())
|
||||
.eqIfPresent(ProcessDO::getDescription, reqVO.getDescription())
|
||||
@@ -39,6 +40,8 @@ public interface ProcessMapper extends BaseMapperX<ProcessDO> {
|
||||
|
||||
IPage<ProcessDO> selectProcessPage(@Param("page") IPage<ProcessDO> page , @Param("page") ProcessPageReqVO reqVO);
|
||||
|
||||
ProcessDO selectOneById(@Param("id") Long id, @Param("organId") Long organId);
|
||||
|
||||
default List<ProcessDO> selectAll() {
|
||||
return selectList(new LambdaQueryWrapperX<ProcessDO>()
|
||||
.orderByDesc(ProcessDO::getId));
|
||||
|
||||
+12
-1
@@ -4,6 +4,8 @@ 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.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||
import com.cf.imes.module.system.dal.dataobject.process.ProcessDO;
|
||||
import com.cf.imes.module.system.dal.dataobject.process.ProcessUserDO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
@@ -18,8 +20,15 @@ import java.util.List;
|
||||
@Mapper
|
||||
public interface ProcessUserMapper extends BaseMapperX<ProcessUserDO> {
|
||||
|
||||
default List<ProcessUserDO> selectByProcessId(Long processId,Long organId) {
|
||||
return selectList(new LambdaQueryWrapperX<ProcessUserDO>()
|
||||
.eq(ProcessUserDO::getProcessId, processId)
|
||||
.eq(ProcessUserDO::getOrganId, organId));
|
||||
}
|
||||
|
||||
default List<ProcessUserDO> selectByProcessId(Long processId) {
|
||||
return selectList(ProcessUserDO::getProcessId, processId);
|
||||
return selectList(new LambdaQueryWrapperX<ProcessUserDO>()
|
||||
.eq(ProcessUserDO::getProcessId, processId));
|
||||
}
|
||||
|
||||
default ProcessUserDO selectUserByProcessId(Long processId) {
|
||||
@@ -27,4 +36,6 @@ public interface ProcessUserMapper extends BaseMapperX<ProcessUserDO> {
|
||||
}
|
||||
|
||||
int deleteUserByProcessId(@Param("processId") Long processId);
|
||||
|
||||
ProcessDO selectOneById(@Param("processId") Long processId, @Param("organId") Long organId);
|
||||
}
|
||||
+14
-18
@@ -1,5 +1,6 @@
|
||||
package com.cf.imes.module.system.service.process;
|
||||
|
||||
import com.cf.imes.framework.organ.core.context.OrganContextHolder;
|
||||
import com.cf.imes.module.system.controller.admin.process.vo.group.ProcessGroupPageReqVO;
|
||||
import com.cf.imes.module.system.controller.admin.process.vo.group.ProcessGroupSaveReqVO;
|
||||
import com.cf.imes.module.system.controller.admin.process.vo.group.ProcessListSaveReqVO;
|
||||
@@ -80,20 +81,18 @@ public class ProcessGroupServiceImpl implements ProcessGroupService {
|
||||
|
||||
@Override
|
||||
public ProcessListSaveReqVO getProcessGroup(Long id) {
|
||||
if (processGroupMapper.selectById(id) == null) {
|
||||
throw exception(PROCESS_GROUP_NOT_EXISTS);
|
||||
} 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++) {
|
||||
if (processMapper.selectById(items[i]) != null)
|
||||
lists.add(BeanUtils.toBean(processMapper.selectById(items[i]), ProcessRespVO.class));
|
||||
}
|
||||
processListSaveReqVO.setLists(lists);
|
||||
return processListSaveReqVO;
|
||||
// 校验存在
|
||||
validateProcessGroupExists(id);
|
||||
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++) {
|
||||
if (processMapper.selectById(Long.valueOf(items[i])) != null)
|
||||
lists.add(BeanUtils.toBean(processMapper.selectById(items[i]), ProcessRespVO.class));
|
||||
}
|
||||
processListSaveReqVO.setLists(lists);
|
||||
return processListSaveReqVO;
|
||||
|
||||
}
|
||||
|
||||
@@ -124,7 +123,7 @@ public class ProcessGroupServiceImpl implements ProcessGroupService {
|
||||
|
||||
itemsList.forEach(itemId -> {
|
||||
try {
|
||||
Object item = processMapper.selectById(itemId);
|
||||
Object item = processMapper.selectById(Long.valueOf(itemId));
|
||||
if (item != null) {
|
||||
// 优化字符串拼接
|
||||
itemsBuilder.append(itemId).append(",");
|
||||
@@ -136,10 +135,7 @@ public class ProcessGroupServiceImpl implements ProcessGroupService {
|
||||
missingItemsBuilder.append(itemId);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
// 处理可能的异常,例如数据库查询异常
|
||||
// 可以记录日志或者转换为业务异常等
|
||||
// 此处为简化仅打印异常,实际应用中应更详细处理
|
||||
System.err.println("Error processing item: " + e.getMessage());
|
||||
throw exception(PROCESS_ID_IS_NULL);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
+2
@@ -59,10 +59,12 @@ public interface ProcessService {
|
||||
* @return 工序信息表 process分页
|
||||
*/
|
||||
PageResult<ProcessRespVO> getProcessPageAll(ProcessPageReqVO pageReqVO);
|
||||
|
||||
/**
|
||||
* 获得所有工序信息表 process
|
||||
*
|
||||
* @return 工序信息表 process
|
||||
*/
|
||||
List<ProcessDO> getAllProcess();
|
||||
|
||||
}
|
||||
+20
-11
@@ -1,13 +1,13 @@
|
||||
package com.cf.imes.module.system.service.process;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.PageDTO;
|
||||
import com.cf.imes.framework.common.util.pinyin.PinYinUtils;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.PageDTO;;
|
||||
import com.cf.imes.framework.common.exception.util.ServiceExceptionUtil;
|
||||
import com.cf.imes.framework.organ.core.context.OrganContextHolder;
|
||||
import com.cf.imes.module.system.controller.admin.process.vo.process.*;
|
||||
import com.cf.imes.module.system.controller.admin.process.vo.processUser.ProcessAndUserSaveReqVO;
|
||||
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.enums.ErrorCodeConstants;
|
||||
import com.cf.imes.module.system.service.user.AdminUserService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@@ -22,7 +22,6 @@ import com.cf.imes.framework.common.util.object.BeanUtils;
|
||||
|
||||
import com.cf.imes.module.system.dal.mysql.process.ProcessMapper;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import static com.cf.imes.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
@@ -51,6 +50,8 @@ public class ProcessServiceImpl implements ProcessService {
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Long createProcess(ProcessUserSaveReqVO createReqVO) {
|
||||
// 用户组织Id
|
||||
// Long organId = OrganContextHolder.getOrganId();
|
||||
// 插入
|
||||
ProcessDO process = BeanUtils.toBean(createReqVO, ProcessDO.class);
|
||||
processMapper.insert(process);
|
||||
@@ -59,11 +60,18 @@ public class ProcessServiceImpl implements ProcessService {
|
||||
String[] usersId = createReqVO.getUsers().split(",");
|
||||
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);
|
||||
// }
|
||||
try{
|
||||
if (adminUserService.getUser(Long.parseLong(user)) == null){
|
||||
throw ServiceExceptionUtil.exception(ErrorCodeConstants.USER_NOT_EXISTS);
|
||||
}
|
||||
|
||||
processAndUserSaveReqVO.setProcessId(processID);
|
||||
processAndUserSaveReqVO.setUserId(Long.parseLong(user));
|
||||
processUserService.createProcessUser(processAndUserSaveReqVO);
|
||||
}catch (Exception e){
|
||||
throw ServiceExceptionUtil.exception(ErrorCodeConstants.USER_NOT_EXISTS);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
// 返回
|
||||
@@ -138,7 +146,7 @@ public class ProcessServiceImpl implements ProcessService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageResult<ProcessDO> getProcessPage(ProcessPageReqVO pageReqVO) {
|
||||
public PageResult<ProcessDO> getProcessPage(ProcessPageReqVO pageReqVO) {//分页加用户
|
||||
return processMapper.selectPage(pageReqVO);
|
||||
}
|
||||
|
||||
@@ -155,4 +163,5 @@ public class ProcessServiceImpl implements ProcessService {
|
||||
return processDOList;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
+5
-1
@@ -1,5 +1,6 @@
|
||||
package com.cf.imes.module.system.service.process;
|
||||
|
||||
import com.cf.imes.framework.organ.core.context.OrganContextHolder;
|
||||
import com.cf.imes.module.system.controller.admin.process.vo.processUser.ProcessAndUserSaveReqVO;
|
||||
import org.springframework.stereotype.Service;
|
||||
import javax.annotation.Resource;
|
||||
@@ -29,6 +30,9 @@ public class ProcessUserServiceImpl implements ProcessUserService {
|
||||
|
||||
@Override
|
||||
public Long createProcessUser(ProcessAndUserSaveReqVO createReqVO) {
|
||||
if (processUserMapper.selectByProcessId(createReqVO.getProcessId()).size() != 0) {
|
||||
throw exception(PROCESS_USER_NOT_EXISTS);
|
||||
}
|
||||
// 插入
|
||||
ProcessUserDO processUser = BeanUtils.toBean(createReqVO, ProcessUserDO.class);
|
||||
processUserMapper.insert(processUser);
|
||||
@@ -48,7 +52,7 @@ public class ProcessUserServiceImpl implements ProcessUserService {
|
||||
@Override
|
||||
public void deleteProcessUserByProcess(Long processId) {
|
||||
// 校验存在
|
||||
validateProcessUserExists(processId);
|
||||
// validateProcessUserExists(processId);
|
||||
// 删除
|
||||
processUserMapper.deleteUserByProcessId(processId);
|
||||
}
|
||||
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
<?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.ProcessGroupMapper">
|
||||
|
||||
<select id="selectOneById" resultType="com.cf.imes.module.system.dal.dataobject.process.ProcessGroupDO">
|
||||
select
|
||||
p.id,
|
||||
p.organ_id,
|
||||
p.name,
|
||||
p.is_default,
|
||||
p.sort,
|
||||
p.items,
|
||||
p.description,
|
||||
p.creator,
|
||||
p.create_time,
|
||||
p.updater,
|
||||
p.update_time,
|
||||
p.deleted
|
||||
from process_group p
|
||||
where p.id = #{id} and p.organ_id = #{organId} and p.deleted = 0
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
+26
-1
@@ -24,7 +24,7 @@
|
||||
p.deleted
|
||||
from process p
|
||||
<where>
|
||||
|
||||
p.deleted = 0
|
||||
<if test="page.userId != null and page.userId != '' ">
|
||||
and p.id in (select process_id from process_user where user_id = #{page.userId})
|
||||
</if>
|
||||
@@ -42,4 +42,29 @@
|
||||
</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<select id="selectOneById" resultType="com.cf.imes.module.system.dal.dataobject.process.ProcessDO">
|
||||
select
|
||||
p.id,
|
||||
p.organ_id,
|
||||
p.name,
|
||||
p.piece_rate,
|
||||
p.piece_type,
|
||||
p.type,
|
||||
p.is_custom,
|
||||
p.is_dealer,
|
||||
p.hour_capacity,
|
||||
p.sort,
|
||||
p.unit,
|
||||
p.is_enabled,
|
||||
p.prepare_time,
|
||||
p.description,
|
||||
p.creator,
|
||||
p.create_time,
|
||||
p.updater,
|
||||
p.update_time,
|
||||
p.deleted
|
||||
from process p
|
||||
where p.id = #{id} and p.organ_id = #{organId} and p.deleted = 0
|
||||
</select>
|
||||
</mapper>
|
||||
+8
-6
@@ -2,15 +2,17 @@
|
||||
<!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>
|
||||
|
||||
<select id="selectOneById" resultType="com.cf.imes.module.system.dal.dataobject.process.ProcessUserDO">
|
||||
select
|
||||
p.organ_id,
|
||||
p.process_id,
|
||||
p.user_id,
|
||||
from process_user p
|
||||
where p.organ_id = #{organId} and p.process_id = #{processId} and p.deleted = 0
|
||||
</select>
|
||||
</mapper>
|
||||
|
||||
Reference in New Issue
Block a user