报表导出1

This commit is contained in:
lym
2024-06-04 16:50:28 +08:00
parent 671d3701e4
commit 026b761c29
35 changed files with 358 additions and 200 deletions
@@ -53,6 +53,7 @@ public class ESDocumentServiceImpl implements ESDocumentService {
document.setOrganId(loginUser.getOrganId());
document.setCreateTime(simpleDateFormat.format(date));
document.setUpdateTime(simpleDateFormat.format(date));
if (StrUtil.isBlank(document.getId())) {
document.setId(snowflake.nextIdStr());
}
@@ -35,6 +35,9 @@ public class GoodsPageReqVO extends PageParam {
@Schema(description = "颜色")
private String color;
@Schema(description = "纹路")
private Integer texture;
@Schema(description = "宽度")
private BigDecimal width;
@@ -43,6 +43,10 @@ public class GoodsRespVO {
@ExcelProperty("颜色")
private String color;
@Schema(description = "纹路", requiredMode = Schema.RequiredMode.REQUIRED)
@ExcelProperty("纹路")
private Integer texture;
@Schema(description = "宽度", requiredMode = Schema.RequiredMode.REQUIRED)
@ExcelProperty("宽度")
private BigDecimal width;
@@ -32,6 +32,9 @@ public class GoodsSaveReqVO {
@Schema(description = "颜色", requiredMode = Schema.RequiredMode.REQUIRED)
private String color;
@Schema(description = "纹路")
private Integer texture;
@Schema(description = "宽度", requiredMode = Schema.RequiredMode.REQUIRED)
private BigDecimal width;
@@ -6,6 +6,7 @@ import com.cf.imes.module.executor.controller.admin.order.vo.order.*;
import com.cf.imes.module.executor.controller.admin.order.vo.product.OrderBodyRespVO;
import com.cf.imes.module.executor.controller.admin.orderParts.vo.OrderPartsRespVO;
import com.cf.imes.module.executor.dal.dataobject.goods.GoodsDO;
import com.cf.imes.module.executor.util.ExcelWriterUtil;
import com.cf.imes.module.executor.util.fileConversion.admin.api.webcad.ApiDataAchieve;
import com.cf.imes.module.executor.util.fileConversion.admin.api.webcad.ApiTypeRealize;
import com.cf.imes.module.executor.util.fileConversion.admin.files.excel.ExcelReadUtil;
@@ -260,12 +261,14 @@ public class OrderController {
Map<String, Object> map = excelReadUtil.read(file);
System.err.println(excelReadUtil.isErr());
// 判断是否读取有误
if (excelReadUtil.isErr() > 1) {
if (excelReadUtil.isErr() == -1) { // 文件为空
ExcelWriterUtil.writeErr(response, "生产单内容为空",orderService.getSavePath()+ "\\"+ "错误文件.xlsx");
return;
}else if (excelReadUtil.isErr() > 0) {
// 返回文件
System.err.println(orderService.getSavePath()+ "生产单Excel导入错误导出模板.xlsx");
excelReadUtil.write(response, (Map<Object, Object>) map.get("order"), (List<OrderPlateImportExcelVO>) map.get("plate"),orderService.getSavePath()+ "\\"+ "生产单Excel导入错误导出模板.xlsx");
throw exception(FILE_READ_ERR);
}else {
ExcelWriterUtil.write(response, (Map<Object, Object>) map.get("order"), (List<OrderPlateImportExcelVO>) map.get("plate"),orderService.getSavePath()+ "\\"+ "生产单Excel导入错误导出模板.xlsx");
return;
} else {
// 获取数据
list = (List<?>) map.get("plate");
orderDO = excelReadUtil.changeOrderDO((Map<Object, Object>) map.get("order")).setOrderType(0).setStatus(1);
@@ -276,7 +279,6 @@ public class OrderController {
}
orderService.importExcelData(orderDO,list);
throw exception(FILE_READ_SUCCESS);
}
@GetMapping("/get-goodsList")
@@ -302,9 +304,11 @@ public class OrderController {
@GetMapping("/printing")
@Operation(summary = "打印/导出")
@PreAuthorize("@ss.hasPermission('executor:order:query')")
@Parameter(name = "type", description = "文件类型", required = true, example = "0")
public CommonResult<String> getOrderPrinting(@Valid OrderPageReqVO pageReqVO, @RequestParam("type") String type) {
return success(orderService.getPrintData(pageReqVO,type));
@PreAuthorize("@ss.hasPermission('executor:order:query')")
@OperateLog(type = EXPORT)
public void getOrderPrinting(@Valid OrderPageReqVO pageReqVO, @RequestParam("type") String type,
HttpServletResponse response) throws IOException {
orderService.getPrintData(pageReqVO,type,response);
}
}
@@ -19,6 +19,9 @@ import static com.cf.imes.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH
@NoArgsConstructor
public class OrderPageReqVO extends PageParam {
@Schema(description = "生产单号")
private Long id;
@Schema(description = "父单号")
private Long parentNo;
@@ -31,8 +31,7 @@ public class OrderSaveReqVO {
@NotNull(message = "生产单类型,1主单 2子单不能为空")
private Boolean orderType;
@Schema(description = "生产单排序号", requiredMode = Schema.RequiredMode.REQUIRED)
@NotNull(message = "生产单排序号不能为空")
@Schema(description = "生产单排序号")
private Integer orderSort;
@Schema(description = "CAD数据类型,1CAD 2WebCAD 3Excel", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
@@ -43,8 +42,7 @@ public class OrderSaveReqVO {
@NotNull(message = "订单状态,订单状态,0空订单1新单2生产中3生产完成")
private Integer status;
@Schema(description = "自定义单号", requiredMode = Schema.RequiredMode.REQUIRED)
@NotEmpty(message = "自定义单号不能为空")
@Schema(description = "自定义单号")
private String customOrderNo;
@Schema(description = "客户", requiredMode = Schema.RequiredMode.REQUIRED)
@@ -67,15 +65,13 @@ public class OrderSaveReqVO {
@NotEmpty(message = "经销商电话不能为空")
private String dealerPhoneNumber;
@Schema(description = "业务员", requiredMode = Schema.RequiredMode.REQUIRED)
@NotEmpty(message = "业务员不能为空")
@Schema(description = "业务员")
private String salesman;
@Schema(description = "拆单员", requiredMode = Schema.RequiredMode.REQUIRED)
@NotEmpty(message = "拆单员不能为空")
@Schema(description = "拆单员")
private String splitter;
@Schema(description = "备注", requiredMode = Schema.RequiredMode.REQUIRED, example = "你猜")
@Schema(description = "备注", example = "你猜")
private String remark;
private Boolean deleted;
@@ -1,24 +0,0 @@
package com.cf.imes.module.executor.controller.admin.order.vo.product;
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
@Schema(description = "管理后台 - 产品信息合集 Response VO")
@Data
@ExcelIgnoreUnannotated
public class ProductRespVO {
// private Long orderId;
private Long roomId;
private String roomName;
private Long bodyId;
private String bodyName;
private Long groupId;
private Long groupTypeId;
private String groupTypeName;
private int goodType;
private String goodName;
private String units;
private Double num;
}
@@ -15,8 +15,7 @@ public class OrderProcessSaveReqVO {
@NotNull(message = "生产单号不能为空")
private Long orderId;
@Schema(description = "工序名", requiredMode = Schema.RequiredMode.REQUIRED, example = "张三")
@NotEmpty(message = "工序组名不能为空")
@Schema(description = "工序名", example = "张三")
private String name;
@Schema(description = "工序组 ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "4356")
@@ -27,10 +26,10 @@ public class OrderProcessSaveReqVO {
@NotNull(message = "工序状态,0未加工,1已加工不能为空")
private Boolean status;
@Schema(description = "板材大小", requiredMode = Schema.RequiredMode.REQUIRED)
@Schema(description = "板材大小", example = "0")
private Double size;
@Schema(description = "下一工序 ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "24046")
@Schema(description = "下一工序 ID", example = "24046")
private Long nextStepId;
private Long organId;
@@ -30,6 +30,9 @@ public class RawGoodsPageReqVO extends PageParam {
@Schema(description = "颜色")
private String color;
@Schema(description = "纹路")
private Integer texture;
@Schema(description = "厚度")
private Double thickness;
@@ -37,6 +37,10 @@ public class RawGoodsRespVO {
@ExcelProperty("颜色")
private String color;
@Schema(description = "纹路", requiredMode = Schema.RequiredMode.REQUIRED)
@ExcelProperty("纹路")
private Integer texture;
@Schema(description = "厚度", requiredMode = Schema.RequiredMode.REQUIRED)
@ExcelProperty("厚度")
private Double thickness;
@@ -32,6 +32,9 @@ public class RawGoodsSaveReqVO {
@NotEmpty(message = "颜色不能为空")
private String color;
@Schema(description = "纹路")
private Integer texture;
@Schema(description = "厚度", requiredMode = Schema.RequiredMode.REQUIRED)
@NotNull(message = "厚度不能为空")
private Double thickness;
@@ -53,6 +53,10 @@ public class GoodsDO extends BaseDO {
* 材质:颗粒板、欧松板、多层板、生态板、禾香板、密度板、实木、铝蜂窝板、铝塑板
*/
private String material;
/**
* 纹路 0 正纹 1 可翻转 2 反纹
*/
private Integer texture;
/**
* 颜色
*/
@@ -51,6 +51,10 @@ public class RawGoodsDO extends BaseDO {
* 颜色
*/
private String color;
/**
* 纹路 0 正纹 1 可翻转 2 反纹
*/
private Integer texture;
/**
* 厚度
*/
@@ -32,6 +32,7 @@ public interface OrderMapper extends BaseMapperX<OrderDO> {
.eqIfPresent(OrderDO::getParentNo, reqVO.getParentNo())
.betweenIfPresent(OrderDO::getDeliveryDate, reqVO.getDeliveryDate())
.betweenIfPresent(OrderDO::getOrderDate, reqVO.getOrderDate())
.eqIfPresent(OrderDO::getId, reqVO.getId())
.eqIfPresent(OrderDO::getOrderType, reqVO.getOrderType())
.eqIfPresent(OrderDO::getOrderSort, reqVO.getOrderSort())
.eqIfPresent(OrderDO::getDataType, reqVO.getDataType())
@@ -62,5 +62,7 @@ public interface OrderPartsMapper extends BaseMapperX<OrderPartsDO> {
IPage<OrderPartsRespVO> selectProductList(@Param("page") IPage<OrderPartsRespVO> page , @Param("orderId")Long orderId, @Param("roomId")Long roomId , @Param("bodyId")Long bodyId);
List<PartGoodsRespVO> selectPartGoodsList(@Param("orderId") Long orderId, @Param("organId") Long organId);
List<PartGoodsRespVO> selectPartDetail(@Param("orderId") Long orderId, @Param("organId") Long organId);// 配件明细
List<PartGoodsRespVO> selectPartAll(@Param("orderId") Long orderId, @Param("organId") Long organId);// 配件汇总
}
@@ -17,6 +17,7 @@ import com.cf.imes.module.executor.dal.dataobject.plate.PlateDO;
import org.springframework.boot.system.ApplicationHome;
import org.springframework.web.multipart.MultipartFile;
import java.io.IOException;
import java.util.Collection;
import java.util.List;
import java.util.Map;
@@ -156,7 +157,7 @@ public interface OrderService {
/**
* 打印/导出数据获取
*/
String getPrintData(OrderPageReqVO orderPageReqVO, String type);
void getPrintData(OrderPageReqVO orderPageReqVO, String type,HttpServletResponse response) throws IOException;
default String getSavePath() {
ApplicationHome applicationHome = new ApplicationHome(this.getClass());
@@ -35,18 +35,22 @@ import com.cf.imes.module.executor.dal.mysql.orderParts.OrderPartsMapper;
import com.cf.imes.module.executor.dal.mysql.plate.PlateGoodMapper;
import com.cf.imes.module.executor.dal.mysql.plate.PlateMapper;
import com.cf.imes.module.executor.dal.mysql.rawgoods.RawGoodsMapper;
import com.cf.imes.module.executor.util.ExcelWriterUtil;
import com.cf.imes.module.executor.util.deviseData.dataTwo.PlateDetail;
import com.cf.imes.module.executor.util.fileConversion.admin.api.webcad.ApiDataProduction;
import com.cf.imes.module.executor.util.fileConversion.admin.api.webcad.ApiTypeRealize;
import com.cf.imes.module.executor.util.fileConversion.admin.files.excel.ExcelTypeRealize;
import com.cf.imes.module.system.api.application.ApplicationApi;
import com.cf.imes.module.system.api.dict.DictDataApi;
import com.cf.imes.module.system.api.dict.dto.DictDataRespDTO;
import com.cf.imes.module.system.api.user.AdminUserApi;
import com.cf.imes.module.system.enums.DictTypeConstants;
import com.cf.imes.module.system.enums.ErrorCodeConstants;
import org.springframework.boot.system.ApplicationHome;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletResponse;
import org.springframework.transaction.annotation.Transactional;
@@ -72,6 +76,7 @@ import java.time.format.DateTimeParseException;
import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.zip.ZipOutputStream;
import static com.cf.imes.framework.common.exception.util.ServiceExceptionUtil.exception;
import static com.cf.imes.module.executor.enums.ErrorCodeConstants.*;
@@ -439,9 +444,11 @@ public class OrderServiceImpl implements OrderService {
}
}
DictDataRespDTO typographyDTO = dictDataApi.getDictData(DictTypeConstants.TYPOGRAPHY_TYPE, String.valueOf(goodsDO.getGoodsId())).getData();// 排版面
Long plateGoods = (Long) identifierGenerator.nextId(null);
PlateGoodDO plateGoodDO = BeanUtils.toBean(goodsDO, PlateGoodDO.class)
.setId(plateGoods)
.setTexture(typographyDTO.getLabel())
.setGoodsId(String.valueOf(goodsDO.getGoodsId()));
goodsDO.setGoodsId(plateGoodDO.getId());
plateGoodLists.add(plateGoodDO);
@@ -596,7 +603,7 @@ public class OrderServiceImpl implements OrderService {
// 根据type获取文件名称
try {
// path是指想要下载的文件的路径
File file = new File(getSavePath()+ "\\" + value);
File file = new File(getSavePath() + "\\" + value);
// 获取文件名
String filename = file.getName();
// 获取文件后缀名
@@ -623,30 +630,38 @@ public class OrderServiceImpl implements OrderService {
}
@Override
public String getPrintData(OrderPageReqVO orderPageReqVO, String type) {
public void getPrintData(OrderPageReqVO orderPageReqVO, String type, HttpServletResponse response) throws IOException {
orderPageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
PageResult<OrderDO> pageResult = orderMapper.selectPage(orderPageReqVO.setOrganId(SecurityFrameworkUtils.getLoginUser().getOrganId()));
List<OrderDO> orderDOList = pageResult.getList();
if (orderDOList == null || orderDOList.size() < 0) {
throw exception(ORDER_NOT_EXISTS);
ExcelWriterUtil.writeErr(response, "生产单查找结果为空", getSavePath() + "\\" + "错误文件.xlsx");
}
List<Map<String, Object>> list = new ArrayList<>();
Map<OrderDO, Object> map = new HashMap();
for (OrderDO orderDO : orderDOList) {
list.add(getDataByOrderIdAndType(orderDO, type));
map.putAll(getDataByOrderIdAndType(orderDO, type));
}
return JSON.toJSONString(list);
ExcelWriterUtil.exportExcel(response, map, getSavePath() + "\\" + type, type);
}
// 根据ype 与 orderId获取相关信息
public Map<String, Object> getDataByOrderIdAndType(OrderDO orderDO, String type) {
Map<String, Object> map = new HashMap<>();
map.put("order", orderDO);
public Map<OrderDO, Object> getDataByOrderIdAndType(OrderDO orderDO, String type) {
Map<OrderDO, Object> map = new HashMap<>();
switch (type) {
case "001":// 板材明细
map.put("plateGoods", plateMapper.selectPlateGoodsList(orderDO.getId(),SecurityFrameworkUtils.getLoginUser().getOrganId()));
case "配件明细1-模板.xlsx":// 配件明细
map.put(orderDO, orderPartsMapper.selectPartDetail(orderDO.getId(), SecurityFrameworkUtils.getLoginUser().getOrganId()));
break;
case "002":// 配件明细
map.put("partGoods", orderPartsMapper.selectPartGoodsList(orderDO.getId(),SecurityFrameworkUtils.getLoginUser().getOrganId()));
case "配件汇总1-模板.xlsx":// 配件汇总
map.put(orderDO, orderPartsMapper.selectPartAll(orderDO.getId(), SecurityFrameworkUtils.getLoginUser().getOrganId()));
break;
case "板材明细-按房间-模板.xlsx"://
break;
case "板材明细-按板材-模板.xlsx"://
break;
case "板材汇总-按房间-模板.xlsx"://
break;
case "板材汇总-按板材-模板.xlsx"://
break;
default:
// 处理默认情况,可以选择忽略或者做其他处理
@@ -0,0 +1,160 @@
package com.cf.imes.module.executor.util;
import com.alibaba.excel.EasyExcel;
import com.alibaba.excel.ExcelWriter;
import com.alibaba.excel.support.ExcelTypeEnum;
import com.alibaba.excel.write.metadata.WriteSheet;
import com.alibaba.excel.write.metadata.WriteTable;
import com.alibaba.excel.write.metadata.fill.FillConfig;
import com.cf.imes.module.executor.dal.dataobject.order.OrderDO;
import com.cf.imes.module.executor.util.fileConversion.admin.files.excel.OrderPlateImportExcelVO;
import org.apache.poi.ss.usermodel.Workbook;
import org.springframework.util.ResourceUtils;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.InputStream;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.zip.ZipEntry;
import java.util.zip.ZipOutputStream;
/**
* excel 文件写入
*/
public class ExcelWriterUtil {
// 写excel
public static void write(HttpServletResponse response,
Map<Object, Object> orderMap,
List<OrderPlateImportExcelVO> list,
String filePathErr) throws IOException {
//输入流
InputStream inputStream = ResourceUtils.getURL(filePathErr).openStream();
ServletOutputStream outputStream = response.getOutputStream();
//设置输出流和模板信息
ExcelWriter excelWriter = EasyExcel.write(outputStream).withTemplate(inputStream).build();
WriteSheet writeSheet = EasyExcel.writerSheet().build();
//开启自动换行,自动换行表示每次写入一条list数据是都会重新生成一行空行,此选项默认是关闭的,需要提前设置为true
FillConfig fillConfig = FillConfig.builder().forceNewRow(Boolean.TRUE).build();
//准备单组和数据
Map<String, String> map = new HashMap<>();
map.put("customOrderNo", (String) orderMap.get("自定义单号"));
map.put("customer", (String) orderMap.get("客户"));
map.put("address", (String) orderMap.get("客户地址"));
map.put("phoneNumber", (String) orderMap.get("客户电话"));
map.put("remark", (String) orderMap.get("备注"));
map.put("splitter", (String) orderMap.get("拆单员"));
map.put("salesman", (String) orderMap.get("业务员"));
map.put("dealerPhoneNumber", (String) orderMap.get("经销商电话"));
map.put("dealer", (String) orderMap.get("经销商"));
map.put("deliveryDate", (String) orderMap.get("出货日期"));
excelWriter.fill(map, writeSheet);
//列表
excelWriter.fill(list, fillConfig, writeSheet);
response.setContentType("application/vnd.ms-excel;charset=UTF-8");
//关流
excelWriter.finish();
inputStream.close();
outputStream.close();
}
// 写excel
public static void writeErr(HttpServletResponse response,
String err,
String filePathErr) throws IOException {
//输入流
InputStream inputStream = ResourceUtils.getURL(filePathErr).openStream();
ServletOutputStream outputStream = response.getOutputStream();
//设置输出流和模板信息
ExcelWriter excelWriter = EasyExcel.write(outputStream).withTemplate(inputStream).build();
WriteSheet writeSheet = EasyExcel.writerSheet().build();
//准备单组和数据
Map<String, String> map = new HashMap<>();
map.put("err", err);
excelWriter.fill(map, writeSheet);
response.setContentType("application/vnd.ms-excel;charset=UTF-8");
//关流
excelWriter.finish();
inputStream.close();
outputStream.close();
}
public static void exportExcel(HttpServletResponse response, Map<OrderDO, Object> map, String filePathErr, String type) throws IOException {
ServletOutputStream outputStream = response.getOutputStream();
ZipOutputStream zipOutputStream = new ZipOutputStream(outputStream);
try {
for (Map.Entry<OrderDO, Object> entry : map.entrySet()) {
OrderDO k = entry.getKey();
Object value = entry.getValue();
// 创建ExcelWriter并填充数据
InputStream inputStream = ResourceUtils.getURL(filePathErr).openStream();
ExcelWriter excelWriter = EasyExcel.write(outputStream)
.withTemplate(inputStream)
.excelType(ExcelTypeEnum.XLS)
.build();
WriteSheet writeSheet = EasyExcel.writerSheet().build();
// 填充订单数据
excelWriter.fill(fillOrderData(k), writeSheet);
// 填充列表数据
excelWriter.fill(value, fillConfig(), writeSheet);
// 写入ZipOutputStream
ZipEntry zipEntry = new ZipEntry(type + "_" + k.getId() + ".xls");
zipOutputStream.putNextEntry(zipEntry);
Workbook workbook = excelWriter.writeContext().writeWorkbookHolder().getWorkbook();
workbook.write(zipOutputStream);
excelWriter.finish(); // 关闭ExcelWriter
// 关闭输入流
inputStream.close();
}
} finally {
// 关闭流
zipOutputStream.close();
outputStream.close();
}
}
// 填充订单数据
private static Map<String, String> fillOrderData(OrderDO order) {
Map<String, String> orderMap = new HashMap<>();
orderMap.put("customOrderNo", order.getCustomOrderNo());
orderMap.put("customer", order.getCustomer());
orderMap.put("address", order.getAddress());
orderMap.put("phoneNumber", order.getPhoneNumber());
orderMap.put("remark", order.getRemark());
orderMap.put("splitter", order.getSplitter());
orderMap.put("salesman", order.getSalesman());
orderMap.put("dealerPhoneNumber", order.getDealerPhoneNumber());
orderMap.put("dealer", order.getDealer());
orderMap.put("deliveryDate", order.getDeliveryDate().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")));
return orderMap;
}
// 填充配置
private static FillConfig fillConfig() {
return FillConfig.builder().forceNewRow(Boolean.TRUE).build();
}
}
@@ -67,7 +67,7 @@ public class ApiTypeRealize {
List<OrderDO> order = new ArrayList<>();
order.add(orderDO);
// 商品信息数据 信息以全
Map<String, Map<Integer, ?>> goodsInfoChange = rawGoodsInfoChange(dataGoods, orderId);
Map<String, Map<Integer, ?>> goodsInfoChange = rawGoodsInfoChange(dataGoods, orderId, dataBlocks);
// System.out.println(" goodsInfoChange " + goodsInfoChange);
List<GoodsDO> goodsDO = (List<GoodsDO>) goodsInfoChange.get("goodsDOS").values().stream()
.collect(Collectors.toList());
@@ -230,6 +230,22 @@ public class ApiTypeRealize {
}
/**
* 板材数据转换成 Map<String, Object>
*/
public Map<Integer, JSONObject> getBlocksDataByGoodsID(JSONObject dataBlocks) {
Map<Integer, JSONObject> map = new HashMap<>();
JSONArray ordersArray = dataBlocks.getJSONArray("List");
if (ordersArray != null && !ordersArray.isEmpty()) {
for (int i = 0; i < ordersArray.size(); i++) {
JSONObject block = ordersArray.getJSONObject(i);
map.put(block.getInteger("GoodsID"), block);
}
}
return map;
}
/**
* raw商品信息转换 和 商品信息转换
*
@@ -239,7 +255,7 @@ public class ApiTypeRealize {
* @author Administrator
* @date 2024/4/30
*/
public Map<String, Map<Integer, ?>> rawGoodsInfoChange(JSONObject dataRawGoods, Long orderId) {
public Map<String, Map<Integer, ?>> rawGoodsInfoChange(JSONObject dataRawGoods, Long orderId , JSONObject dataBlocks) {
Map<String, Map<Integer, ?>> map = new HashMap<>();
Map<Integer, RawGoodsDO> rawGoodsDOS = new HashMap<>();
Map<Integer, GoodsDO> goodsDOS = new HashMap<>();
@@ -257,6 +273,7 @@ public class ApiTypeRealize {
.goodsName(goods.getString("GoodsName"))
.material(goods.getString("Material"))
.color(goods.getString("Color"))
.texture(goods.getInteger("Wave"))
.thickness(goods.getDouble("Thickness"))
.price(goods.getDouble("Price"))
.brand(goods.getString("Brand"))
@@ -272,6 +289,7 @@ public class ApiTypeRealize {
.goodsName(goods.getString("GoodsName"))
.material(goods.getString("Material"))
.color(goods.getString("Color"))
.texture(goods.getInteger("Wave"))
.width(BigDecimal.valueOf(goods.getDouble("Width")))
.height(BigDecimal.valueOf(goods.getDouble("Height")))
.thickness(BigDecimal.valueOf(goods.getDouble("Thickness")))
@@ -1,48 +1,48 @@
package com.cf.imes.module.executor.util.fileConversion.admin.api.webcad;
import org.springframework.aop.interceptor.AsyncUncaughtExceptionHandler;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.AsyncConfigurer;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
import java.util.concurrent.Executor;
import java.util.concurrent.ThreadPoolExecutor;
/**
* @Description: 配置类实现AsyncConfigurer接口,并重写getAsyncExecutor方法,并返回一个ThreadPoolTaskExecutor
* 这样我们就获得一个基于线程池TaskExecutor
* 利用@EnableAsync注解开启异步任务支持
* @ClassName: MultiThreadingConfig
* @Author: xiaolege
*/
@Configuration
@ComponentScan("com.cf.imes.module.executor.service.order")
@EnableAsync
public class MultiThreadingConfig implements AsyncConfigurer {
@Override
public Executor getAsyncExecutor() {
ThreadPoolTaskExecutor taskExecutor = new ThreadPoolTaskExecutor();
//最小线程数
taskExecutor.setCorePoolSize(5);
//最大线程数
taskExecutor.setMaxPoolSize(10);
//等待队列
taskExecutor.setQueueCapacity(50);
taskExecutor.setKeepAliveSeconds(600);
//设置拒绝策略
taskExecutor.setRejectedExecutionHandler(new ThreadPoolExecutor.CallerRunsPolicy());
//等待所有任务结束后再关闭线程池
// taskExecutor.setWaitForTasksToCompleteOnShutdown(true);
taskExecutor.initialize();
return taskExecutor;
}
@Override
public AsyncUncaughtExceptionHandler getAsyncUncaughtExceptionHandler() {
return AsyncConfigurer.super.getAsyncUncaughtExceptionHandler();
}
}
//package com.cf.imes.module.executor.util.fileConversion.admin.api.webcad;
//
//import org.springframework.aop.interceptor.AsyncUncaughtExceptionHandler;
//import org.springframework.context.annotation.ComponentScan;
//import org.springframework.context.annotation.Configuration;
//import org.springframework.scheduling.annotation.AsyncConfigurer;
//import org.springframework.scheduling.annotation.EnableAsync;
//import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
//
//import java.util.concurrent.Executor;
//import java.util.concurrent.ThreadPoolExecutor;
//
///**
// * @Description: 配置类实现AsyncConfigurer接口,并重写getAsyncExecutor方法,并返回一个ThreadPoolTaskExecutor
// * 这样我们就获得一个基于线程池TaskExecutor
// * 利用@EnableAsync注解开启异步任务支持
// * @ClassName: MultiThreadingConfig
// * @Author: xiaolege
// */
//@Configuration
//@ComponentScan("com.cf.imes.module.executor.service.order")
//@EnableAsync
//public class MultiThreadingConfig implements AsyncConfigurer {
//
// @Override
// public Executor getAsyncExecutor() {
// ThreadPoolTaskExecutor taskExecutor = new ThreadPoolTaskExecutor();
// //最小线程数
// taskExecutor.setCorePoolSize(5);
// //最大线程数
// taskExecutor.setMaxPoolSize(10);
// //等待队列
// taskExecutor.setQueueCapacity(50);
// taskExecutor.setKeepAliveSeconds(600);
// //设置拒绝策略
// taskExecutor.setRejectedExecutionHandler(new ThreadPoolExecutor.CallerRunsPolicy());
// //等待所有任务结束后再关闭线程池
//// taskExecutor.setWaitForTasksToCompleteOnShutdown(true);
// taskExecutor.initialize();
// return taskExecutor;
// }
//
// @Override
// public AsyncUncaughtExceptionHandler getAsyncUncaughtExceptionHandler() {
// return AsyncConfigurer.super.getAsyncUncaughtExceptionHandler();
// }
//
//}
@@ -7,7 +7,6 @@ import com.alibaba.excel.write.metadata.WriteSheet;
import com.alibaba.excel.write.metadata.fill.FillConfig;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.nacos.common.utils.DateFormatUtils;
import com.alibaba.nacos.common.utils.StringUtils;
import com.cf.imes.framework.organ.core.context.OrganContextHolder;
import com.cf.imes.module.executor.dal.dataobject.order.OrderDO;
@@ -15,11 +14,6 @@ import com.cf.imes.module.system.api.dict.DictDataApi;
import com.cf.imes.module.system.api.dict.dto.DictDataRespDTO;
import com.cf.imes.module.system.enums.DictTypeConstants;
import lombok.extern.slf4j.Slf4j;
import org.apache.poi.hssf.usermodel.HSSFDateUtil;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.xssf.usermodel.XSSFRow;
import org.apache.poi.xssf.usermodel.XSSFSheet;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.springframework.stereotype.Component;
import org.springframework.util.ResourceUtils;
import org.springframework.web.multipart.MultipartFile;
@@ -28,24 +22,15 @@ import javax.annotation.Resource;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletResponse;
import java.io.*;
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
import java.text.DecimalFormat;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.*;
import static com.cf.imes.framework.common.exception.util.ServiceExceptionUtil.exception;
import static com.cf.imes.module.executor.enums.ErrorCodeConstants.ORDER_NOT_EXISTS;
@Slf4j
@Component
public class ExcelReadUtil { // 文件读取
private String value;
private Boolean index = true;
private int isErr;
@@ -71,7 +56,6 @@ public class ExcelReadUtil { // 文件读取
index = false;
}
if (index) {
System.out.println(item);
orderMap.put(item.get(0), item.get(1));
orderMap.put(item.get(12), item.get(13));
} else {
@@ -84,9 +68,8 @@ public class ExcelReadUtil { // 文件读取
);
index = true;
map.put("order", orderMap);
System.err.println(map.get("order"));
if (orderMap.size() == 0)
throw exception(ORDER_NOT_EXISTS);
isErr = -1;
map.put("plate", list);
return map;
@@ -126,48 +109,6 @@ public class ExcelReadUtil { // 文件读取
return dateTime;
}
// 写excel
public void write(HttpServletResponse response,
Map<Object, Object> orderMap,
List<OrderPlateImportExcelVO> list,
String filePathErr) throws IOException {
//输入流
// InputStream inputStream = this.getClass().getClassLoader().getResourceAsStream("templates/生产单新增Excel模板.xlsx");
InputStream inputStream = ResourceUtils.getURL(filePathErr).openStream();
ServletOutputStream outputStream = response.getOutputStream();
//设置输出流和模板信息
ExcelWriter excelWriter = EasyExcel.write(outputStream).withTemplate(inputStream).build();
WriteSheet writeSheet = EasyExcel.writerSheet().build();
//开启自动换行,自动换行表示每次写入一条list数据是都会重新生成一行空行,此选项默认是关闭的,需要提前设置为true
FillConfig fillConfig = FillConfig.builder().forceNewRow(Boolean.TRUE).build();
//列表
excelWriter.fill(list, fillConfig, writeSheet);
//准备单组和数据
Map<String, String> map = new HashMap<>();
map.put("customOrderNo", (String) orderMap.get("customOrderNo"));
map.put("customer", (String) orderMap.get("customer"));
map.put("address", (String) orderMap.get("address"));
map.put("phoneNumber", (String) orderMap.get("phoneNumber"));
map.put("remark", (String) orderMap.get("remark"));
map.put("splitter", (String) orderMap.get("splitter"));
map.put("salesman", (String) orderMap.get("salesman"));
map.put("dealerPhoneNumber", (String) orderMap.get("dealerPhoneNumber"));
map.put("dealer", (String) orderMap.get("dealer"));
excelWriter.fill(map, writeSheet);
// response.addHeader("Baeldung-Example-Header", "Value-HttpServletResponse");
response.setContentType("application/vnd.ms-excel;charset=UTF-8");
//关流
excelWriter.finish();
inputStream.close();
outputStream.close();
}
// 赋值单元格数据
private OrderPlateImportExcelVO changeValue(Map<Integer, String> dataMap) {
OrderPlateImportExcelVO vo = new OrderPlateImportExcelVO();
@@ -41,7 +41,8 @@ public class ExcelTypeRealize {
// 数据转换 + 错误验证
public Map<String, List<?>> changeDate(List<?> list, Long orderId) {
if (list.isEmpty()){
throw exception(FILE_UPLOAD_ERR);
// throw exception(FILE_UPLOAD_ERR);
return null;
}
List<OrderPlateImportExcelVO> excelVOS = (List<OrderPlateImportExcelVO>) list;
@@ -253,12 +254,12 @@ public class ExcelTypeRealize {
.goodsName(excelVO.getGoodsName())
.material(excelVO.getMaterial())
.color(excelVO.getColor())
.texture("")
.width(Double.valueOf(excelVO.getWidth()))
.height(Double.valueOf(excelVO.getHeight()))
.thickness(Double.valueOf(excelVO.getThickness()))
.spec(excelVO.getSpec())
.brand(excelVO.getBrand())
.texture(excelVO.getTexture())
// .organId(organId)
.build();
}
@@ -275,6 +276,7 @@ public class ExcelTypeRealize {
.thickness(Double.valueOf(excelVO.getThickness()))
.spec(excelVO.getSpec())
.brand(excelVO.getBrand())
.texture(Integer.valueOf(excelVO.getTexture()))
.build();
}
@@ -30,9 +30,8 @@ public class OrderPlateImportExcelVO {
@JsonIgnore
private String ordinal;
@ExcelProperty(value = "类型", converter = DictConvert.class)
@ExcelProperty(value = "类型")
@JsonIgnore
@DictFormat(DictTypeConstants.PRODUCT_TYPE)
private String goodType;
@ExcelProperty(value = "物料编码")
@@ -86,9 +85,8 @@ public class OrderPlateImportExcelVO {
@JsonIgnore
private String cabinetsName;
@ExcelProperty(value = "加工组类型", converter = DictConvert.class)
@ExcelProperty(value = "加工组类型")
@JsonIgnore
@DictFormat(DictTypeConstants.SYNTHESIS_TYPE)
private String synthesis;
@JsonIgnore
@@ -143,19 +141,16 @@ public class OrderPlateImportExcelVO {
@JsonIgnore
private String sealDown;
@ExcelProperty(value = "排版面", converter = DictConvert.class)
@ExcelProperty(value = "排版面")
@JsonIgnore
@DictFormat(DictTypeConstants.TYPOGRAPHY_TYPE)
private String typographicFace;
@ExcelProperty(value = "纹路", converter = DictConvert.class)
@ExcelProperty(value = "纹路")
@JsonIgnore
@DictFormat(DictTypeConstants.GRAIN_TYPE)
private String texture;
@ExcelProperty(value = "开门方向", converter = DictConvert.class)
@ExcelProperty(value = "开门方向")
@JsonIgnore
@DictFormat(DictTypeConstants.DOOR_OPENING_DIRECTIONS)
private String openDoorType;
@ExcelProperty(value = "上传结果")
@@ -14,15 +14,37 @@
</select>
<select id="selectPartGoodsList"
<select id="selectPartDetail"
resultType="com.cf.imes.module.executor.controller.admin.orderParts.vo.PartGoodsRespVO">
SELECT a.id, a.goods_id, a.name, a.material, a.type, a.model, a.spec, a.brand, a.factory,
a.unit, a.price, a.is_composite, a.remark, b.num, c.name as body_name, c.id as body_id,
c.room_id, c.room_name
c.room_id, c.room_name, b.num * a.price AS total_price -- 添加计算总金额的列
FROM order_parts a
LEFT JOIN order_item b ON a.id = b.parts_id
LEFT JOIN order_body c on c.id = b.body_id
WHERE b.order_id = #{orderId}
and b.organ_id = #{organId}
</select>
<select id="selectPartAll"
resultType="com.cf.imes.module.executor.controller.admin.orderParts.vo.PartGoodsRespVO">
SELECT
a.name,
a.brand,
a.model,
a.spec,
a.unit,
a.price,
a.remark,
b.num
FROM
order_parts a
LEFT JOIN
order_item b ON a.id = b.parts_id
WHERE
b.order_id = #{orderId}
AND b.organ_id = #{organId}
</select>
</mapper>
@@ -307,6 +307,7 @@
left join order_goods ogs on op.goods_id = ogs.id
left join order_item its on op.id = its.plate_id
left join order_body bdy on bdy.id = its.body_id
left join order_goods gods on gods.id = op.goods_id
where op.order_id = #{orderId}
and op.organ_id = #{organId}
</select>
@@ -45,19 +45,16 @@ public class PlateSaveReqVO {
@NotNull(message = "厚度不能为空")
private Double thickness;
@Schema(description = "价格", requiredMode = Schema.RequiredMode.REQUIRED, example = "3380")
@NotNull(message = "价格不能为空")
@Schema(description = "价格", example = "3380")
private Double price;
@Schema(description = "品牌", requiredMode = Schema.RequiredMode.REQUIRED)
@NotEmpty(message = "品牌不能为空")
@Schema(description = "品牌")
private String brand;
@Schema(description = "规格", requiredMode = Schema.RequiredMode.REQUIRED)
@NotEmpty(message = "规格不能为空")
@Schema(description = "规格")
private String spec;
@Schema(description = "备注", requiredMode = Schema.RequiredMode.REQUIRED, example = "随便")
@Schema(description = "备注", example = "随便")
private String remark;
private Long organId;
@@ -53,24 +53,20 @@ public class RemainPlateSaveReqVO {
@NotNull(message = "厚度不能为空")
private BigDecimal thickness;
@Schema(description = "品牌", requiredMode = Schema.RequiredMode.REQUIRED)
@NotEmpty(message = "品牌不能为空")
@Schema(description = "品牌")
private String brand;
@Schema(description = "放置样式,0正面,1正面右转,2正面后转,3正面左转,4反面,5反面右转,6反面后转,7反面左转", requiredMode = Schema.RequiredMode.REQUIRED)
@NotNull(message = "放置样式,0正面,1正面右转,2正面后转,3正面左转,4反面,5反面右转,6反面后转,7反面左转不能为空")
@Schema(description = "放置样式,0正面,1正面右转,2正面后转,3正面左转,4反面,5反面右转,6反面后转,7反面左转")
private Integer placeStyle;
@Schema(description = "仓库名", requiredMode = Schema.RequiredMode.REQUIRED)
@NotEmpty(message = "仓库名不能为空")
@Schema(description = "仓库名")
private String store;
@Schema(description = "数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "18318")
@NotNull(message = "数量不能为空")
private Integer count;
@Schema(description = "备注", requiredMode = Schema.RequiredMode.REQUIRED, example = "随便")
@NotEmpty(message = "备注不能为空")
@Schema(description = "备注", example = "随便")
private String remark;
@Schema(description = "轮廊数据,Json 串", requiredMode = Schema.RequiredMode.REQUIRED)