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:
+24
@@ -0,0 +1,24 @@
|
||||
package com.cf.imes.module.executor.enums;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
public enum OrderStatusEnum {
|
||||
EMPTY(0, "空生产单"),
|
||||
NEW_ORDER(1, "新单"),
|
||||
IN_PRODUCTION(2, "生产中"),
|
||||
FINISH_PRODUCTION(3, "生产完成");
|
||||
|
||||
private final Integer status;
|
||||
private String description;
|
||||
|
||||
public boolean equals(Integer status) {
|
||||
return this.status .equals(status) ;
|
||||
}
|
||||
|
||||
public boolean equals(OrderStatusEnum enableStatusEnum) {
|
||||
return enableStatusEnum != null && enableStatusEnum.status .equals(this.getStatus()) ;
|
||||
}
|
||||
}
|
||||
+18
-5
@@ -302,13 +302,26 @@ public class OrderController {
|
||||
return success(orderService.importTemplate(file,type));
|
||||
}
|
||||
|
||||
@GetMapping("/printing")
|
||||
@Operation(summary = "打印/导出")
|
||||
@GetMapping("/printingZip")
|
||||
@Operation(summary = "打印/导出(多文件)")
|
||||
@Parameter(name = "type", description = "文件类型", required = true, example = "0")
|
||||
@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);
|
||||
public void getOrderPrintingZip(@Valid OrderPageReqVO pageReqVO,
|
||||
@RequestParam("type") String type,
|
||||
HttpServletResponse response) throws IOException {
|
||||
orderService.getPrintDataZip(pageReqVO,type,response);
|
||||
}
|
||||
|
||||
@GetMapping("/printing")
|
||||
@Operation(summary = "打印/导出(单文件)")
|
||||
@Parameter(name = "type", description = "文件类型", required = true, example = "0")
|
||||
@PreAuthorize("@ss.hasPermission('executor:order:query')")
|
||||
@OperateLog(type = EXPORT)
|
||||
public void getOrderPrinting(
|
||||
// @RequestParam("orderId") Long orderId,
|
||||
@RequestParam("type") String type,
|
||||
HttpServletResponse response) throws IOException {
|
||||
orderService.getPrintData(1797937673478864896L,type,response);
|
||||
}
|
||||
}
|
||||
+3
@@ -74,4 +74,7 @@ public class PartGoodsRespVO {
|
||||
|
||||
@Schema(description = "数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "29507")
|
||||
private Double num;
|
||||
|
||||
@Schema(description = "金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "29507")
|
||||
private Double totalPrice;
|
||||
}
|
||||
|
||||
+9
@@ -114,4 +114,13 @@ public interface OrderMapper extends BaseMapperX<OrderDO> {
|
||||
.eq(OrderDO::getDeleted, 0)
|
||||
.eq(OrderDO::getOrganId, organId));
|
||||
}
|
||||
|
||||
// 查询单个生产单
|
||||
default OrderDO selectOrderOne(Long id,Long organId) {
|
||||
return selectOne(new LambdaQueryWrapper<OrderDO>()
|
||||
.select(OrderDO::getStatus)
|
||||
.eq(OrderDO::getId, id)
|
||||
.eq(OrderDO::getDeleted, 0)
|
||||
.eq(OrderDO::getOrganId, organId));
|
||||
}
|
||||
}
|
||||
|
||||
+7
-2
@@ -155,9 +155,14 @@ public interface OrderService {
|
||||
void exportTemplate(HttpServletResponse response, String value);
|
||||
|
||||
/**
|
||||
* 打印/导出数据获取
|
||||
* 打印/导出数据获取 (多文件)
|
||||
*/
|
||||
void getPrintData(OrderPageReqVO orderPageReqVO, String type,HttpServletResponse response) throws IOException;
|
||||
void getPrintDataZip(OrderPageReqVO orderPageReqVO, String type,HttpServletResponse response) throws IOException;
|
||||
|
||||
/**
|
||||
* 打印/导出数据获取 (单文件)
|
||||
*/
|
||||
void getPrintData(Long orderId, String type,HttpServletResponse response) throws IOException;
|
||||
|
||||
default String getSavePath() {
|
||||
ApplicationHome applicationHome = new ApplicationHome(this.getClass());
|
||||
|
||||
+52
-12
@@ -35,11 +35,13 @@ 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.enums.OrderStatusEnum;
|
||||
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.executor.util.fileConversion.admin.files.excel.OrderPlateImportExcelVO;
|
||||
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;
|
||||
@@ -275,13 +277,14 @@ public class OrderServiceImpl implements OrderService {
|
||||
public void deleteBodyByOrder(Long orderId, Collection<Long> bodyIds) {
|
||||
validateOrderExists(orderId);
|
||||
// 校验生产单的状态 1 为新单状态,才可以修改
|
||||
if (orderMapper.selectOne(new LambdaQueryWrapper<OrderDO>().eq(OrderDO::getId, orderId).eq(OrderDO::getStatus, 1)).getStatus() == 1) {
|
||||
if (orderMapper.selectOrderOne(orderId, OrganContextHolder.getOrganId()).getStatus() !=
|
||||
OrderStatusEnum.NEW_ORDER.getStatus()) {
|
||||
throw exception(ORDER_STATUS_ERROR);
|
||||
}
|
||||
if (CollectionUtils.isNotEmpty(bodyIds)) {
|
||||
bodyIds.forEach(bodyId -> {
|
||||
// 校验存在
|
||||
validateOrderBodyExists(orderId, bodyId);
|
||||
validateOrderBodyExists(orderId, bodyId, OrganContextHolder.getOrganId());
|
||||
// 删除
|
||||
orderBodyMapper.deleteAllByOrderId(orderId, bodyId);
|
||||
});
|
||||
@@ -444,11 +447,9 @@ 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);
|
||||
@@ -458,15 +459,16 @@ public class OrderServiceImpl implements OrderService {
|
||||
return map;
|
||||
}
|
||||
|
||||
private void validateOrderBodyExists(Long orderId, Long bodyId) {
|
||||
if (orderBodyMapper.selectCount(new LambdaQueryWrapper<OrderBodyDO>().eq(OrderBodyDO::getOrderId, orderId).eq(OrderBodyDO::getId, bodyId)) == 0) {
|
||||
private void validateOrderBodyExists(Long orderId, Long bodyId, Long organId) {
|
||||
if (orderBodyMapper.selectCount(new LambdaQueryWrapper<OrderBodyDO>()
|
||||
.eq(OrderBodyDO::getOrderId, orderId)
|
||||
.eq(OrderBodyDO::getId, bodyId)
|
||||
.eq(OrderBodyDO::getOrganId, organId)) == 0) {
|
||||
throw exception(ORDER_BODY_NOT_EXISTS);
|
||||
}
|
||||
}
|
||||
|
||||
private LocalDateTime getAfterDate(LocalDateTime date) {
|
||||
// 获取当前日期类型 2024-03-06 16:50:15
|
||||
// 获取当前日期,明确指定时区为业务所在时区,例如Asia/Shanghai
|
||||
ZonedDateTime now = ZonedDateTime.now(ZoneId.of("UTC"));
|
||||
LocalDateTime localDateTime = now.toLocalDateTime();
|
||||
|
||||
@@ -474,12 +476,10 @@ public class OrderServiceImpl implements OrderService {
|
||||
// 添加30天
|
||||
LocalDateTime futureDate = localDateTime.plusDays(DEFAULT_DAYS_TO_ADD);
|
||||
try {
|
||||
// 考虑到异常处理,使用try-catch块
|
||||
return futureDate;
|
||||
} catch (DateTimeParseException e) {
|
||||
// 在实际应用中应该有更详细的错误处理逻辑
|
||||
System.err.println("Error parsing future date: " + e.getMessage());
|
||||
// 根据业务需求,这里可以选择记录日志、抛出自定义异常或进行其他处理
|
||||
}
|
||||
}
|
||||
return date;
|
||||
@@ -630,7 +630,7 @@ public class OrderServiceImpl implements OrderService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getPrintData(OrderPageReqVO orderPageReqVO, String type, HttpServletResponse response) throws IOException {
|
||||
public void getPrintDataZip(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();
|
||||
@@ -642,7 +642,19 @@ public class OrderServiceImpl implements OrderService {
|
||||
for (OrderDO orderDO : orderDOList) {
|
||||
map.putAll(getDataByOrderIdAndType(orderDO, type));
|
||||
}
|
||||
ExcelWriterUtil.exportExcel(response, map, getSavePath() + "\\" + type, type);
|
||||
ExcelWriterUtil.exportExcelZip(response, map, getSavePath() + "\\" + type, type);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getPrintData(Long orderId, String type, HttpServletResponse response) throws IOException {
|
||||
// 查询生产单
|
||||
OrderDO orderDO = orderMapper.selectById(orderId);
|
||||
if (orderDO == null) {
|
||||
ExcelWriterUtil.writeErr(response, "生产单查找结果为空", getSavePath() + "\\" + "错误文件.xlsx");
|
||||
}
|
||||
|
||||
Map<Long, Object> map = getDataByOrderIdAndType(orderId, type);
|
||||
ExcelWriterUtil.exportExcel(response, orderDO, (List<OrderPlateImportExcelVO>) map.get(orderDO.getId()), getSavePath(), type);
|
||||
}
|
||||
|
||||
// 根据ype 与 orderId获取相关信息
|
||||
@@ -673,6 +685,34 @@ public class OrderServiceImpl implements OrderService {
|
||||
return map;
|
||||
}
|
||||
|
||||
// 根据ype 与 orderId获取相关信息
|
||||
public Map<Long, Object> getDataByOrderIdAndType(Long orderId, String type) {
|
||||
Map<Long, Object> map = new HashMap<>();
|
||||
switch (type) {
|
||||
case "配件明细1-模板.xlsx":// 配件明细
|
||||
map.put(orderId, orderPartsMapper.selectPartDetail(orderId, SecurityFrameworkUtils.getLoginUser().getOrganId()));
|
||||
break;
|
||||
case "配件汇总1-模板.xlsx":// 配件汇总
|
||||
map.put(orderId, orderPartsMapper.selectPartAll(orderId, SecurityFrameworkUtils.getLoginUser().getOrganId()));
|
||||
break;
|
||||
case "板材明细-按房间-模板.xlsx":
|
||||
break;
|
||||
case "板材明细-按板材-模板.xlsx":
|
||||
map.put(orderId, plateMapper.selectPlateGoodsList(orderId, SecurityFrameworkUtils.getLoginUser().getOrganId()));
|
||||
|
||||
break;
|
||||
case "板材汇总-按房间-模板.xlsx":
|
||||
break;
|
||||
case "板材汇总-按板材-模板.xlsx":
|
||||
map.put(orderId, plateMapper.selectPlateGoodsList(orderId, SecurityFrameworkUtils.getLoginUser().getOrganId()));
|
||||
break;
|
||||
default:
|
||||
// 处理默认情况,可以选择忽略或者做其他处理
|
||||
break;
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
public String getRandomNumber(int length) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
Random random = new Random();
|
||||
|
||||
+1
-1
@@ -69,7 +69,7 @@ public class OrderProcessServiceImpl implements OrderProcessService {
|
||||
private OrderBodyMapper orderBodyMapper;
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Long createOrderProcess(OrderProcessSaveReqVO createReqVO) {
|
||||
// 当生产不为删除时,校验生产单存在
|
||||
if (orderMapper.selectOrder(createReqVO.getOrderId(), SecurityFrameworkUtils.getLoginUser().getOrganId()).isEmpty()) {
|
||||
|
||||
+41
-1
@@ -15,6 +15,7 @@ import javax.servlet.ServletOutputStream;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.net.URLEncoder;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.HashMap;
|
||||
@@ -97,7 +98,7 @@ public class ExcelWriterUtil {
|
||||
outputStream.close();
|
||||
}
|
||||
|
||||
public static void exportExcel(HttpServletResponse response, Map<OrderDO, Object> map, String filePathErr, String type) throws IOException {
|
||||
public static void exportExcelZip(HttpServletResponse response, Map<OrderDO, Object> map, String filePathErr, String type) throws IOException {
|
||||
ServletOutputStream outputStream = response.getOutputStream();
|
||||
ZipOutputStream zipOutputStream = new ZipOutputStream(outputStream);
|
||||
|
||||
@@ -136,10 +137,49 @@ public class ExcelWriterUtil {
|
||||
}
|
||||
}
|
||||
|
||||
public static void exportExcel(HttpServletResponse response,
|
||||
OrderDO orderDO,
|
||||
List<OrderPlateImportExcelVO> list,
|
||||
String filePathErr,
|
||||
String type) throws IOException {
|
||||
//输入流
|
||||
InputStream inputStream = ResourceUtils.getURL(filePathErr+ "\\" + type).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> mapOrder = fillOrderData(orderDO);
|
||||
|
||||
excelWriter.fill(mapOrder, writeSheet);
|
||||
|
||||
//列表
|
||||
excelWriter.fill(list, fillConfig, writeSheet);
|
||||
|
||||
//设置文件名的编码格式,防止文件名乱码
|
||||
String fileName = URLEncoder.encode(type.replace("模板",String.valueOf(orderDO.getId())), "UTF-8");
|
||||
//固定写法,设置响应头
|
||||
response.setHeader("Content-disposition", "attachment;filename="+ fileName + ".xlsx");
|
||||
|
||||
response.setContentType("application/vnd.ms-excel;charset=UTF-8");
|
||||
//关流
|
||||
excelWriter.finish();
|
||||
inputStream.close();
|
||||
outputStream.close();
|
||||
}
|
||||
|
||||
// 填充订单数据
|
||||
private static Map<String, String> fillOrderData(OrderDO order) {
|
||||
Map<String, String> orderMap = new HashMap<>();
|
||||
orderMap.put("customOrderNo", order.getCustomOrderNo());
|
||||
orderMap.put("orderId", order.getId().toString());
|
||||
orderMap.put("orderData", order.getOrderDate().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")));
|
||||
orderMap.put("customer", order.getCustomer());
|
||||
orderMap.put("address", order.getAddress());
|
||||
orderMap.put("phoneNumber", order.getPhoneNumber());
|
||||
|
||||
+1
-1
@@ -113,7 +113,7 @@
|
||||
from order_goods a
|
||||
left join order_plate b on a.goods_id = b.goods_id
|
||||
left join order_item c on c.order_id = b.order_id
|
||||
left join order_remain_plate d on a.goods_id = d.goods_id and d.plan_id = c.plan_id
|
||||
left join order_remain_plate d on a.goods_id = d.goods_id and d.plan_id = c.plan_id
|
||||
where c.plan_id = #{planId}
|
||||
GROUP BY a.id, d.id
|
||||
|
||||
|
||||
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
Reference in New Issue
Block a user