From 25f0001a7e76d0565fa9de0651f1177b9f61472f Mon Sep 17 00:00:00 2001
From: zhou zhou <zozhouo3o@gmail.com>
Date: 星期四, 07 五月 2026 17:12:00 +0800
Subject: [PATCH] #order打印
---
rsf-server/src/main/java/com/vincent/rsf/server/manager/service/impl/AsnOrderLogServiceImpl.java | 228 +++++++++++++++++++++++++++++++++++++++++++++++++++++++--
1 files changed, 220 insertions(+), 8 deletions(-)
diff --git a/rsf-server/src/main/java/com/vincent/rsf/server/manager/service/impl/AsnOrderLogServiceImpl.java b/rsf-server/src/main/java/com/vincent/rsf/server/manager/service/impl/AsnOrderLogServiceImpl.java
index 2b7b816..232d2f6 100644
--- a/rsf-server/src/main/java/com/vincent/rsf/server/manager/service/impl/AsnOrderLogServiceImpl.java
+++ b/rsf-server/src/main/java/com/vincent/rsf/server/manager/service/impl/AsnOrderLogServiceImpl.java
@@ -1,37 +1,48 @@
package com.vincent.rsf.server.manager.service.impl;
+import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
import com.vincent.rsf.framework.common.R;
import com.vincent.rsf.framework.exception.CoolException;
import com.vincent.rsf.server.manager.entity.WkOrder;
import com.vincent.rsf.server.manager.entity.WkOrderItem;
import com.vincent.rsf.server.manager.entity.AsnOrderItemLog;
import com.vincent.rsf.server.manager.enums.AsnExceStatus;
+import com.vincent.rsf.server.manager.mapper.AsnOrderMapper;
import com.vincent.rsf.server.manager.mapper.AsnOrderLogMapper;
import com.vincent.rsf.server.manager.entity.AsnOrderLog;
+import com.vincent.rsf.server.manager.partition.AsnLogPartitionSupport;
import com.vincent.rsf.server.manager.service.AsnOrderItemLogService;
import com.vincent.rsf.server.manager.service.AsnOrderItemService;
import com.vincent.rsf.server.manager.service.AsnOrderLogService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
-import com.vincent.rsf.server.manager.service.AsnOrderService;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
+import java.io.Serializable;
import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.LinkedHashMap;
import java.util.List;
+import java.util.Map;
import java.util.Objects;
@Service("asnOrderLogService")
public class AsnOrderLogServiceImpl extends ServiceImpl<AsnOrderLogMapper, AsnOrderLog> implements AsnOrderLogService {
@Autowired
+ private AsnLogPartitionSupport partitionSupport;
+ @Autowired
private AsnOrderItemLogService asnOrderItemLogService;
@Autowired
private AsnOrderItemService asnOrderItemService;
@Autowired
- private AsnOrderService asnOrderService;
+ private AsnOrderMapper asnOrderMapper;
/**
* @author Ryan
* @description 缁х画鏀惰揣
@@ -42,7 +53,7 @@
@Override
@Transactional(rollbackFor = Exception.class)
public R continueRecipt(Long id) {
- AsnOrderLog orderLog = this.getOne(new LambdaQueryWrapper<AsnOrderLog>().eq(AsnOrderLog::getId, id));
+ AsnOrderLog orderLog = this.getById(id);
if (Objects.isNull(orderLog)) {
throw new CoolException("鍗曟嵁涓嶅瓨鍦紒锛�");
}
@@ -52,25 +63,25 @@
.setDeleted(0)
.setExceStatus(AsnExceStatus.ASN_EXCE_STATUS_EXCE_ING.val);
- WkOrder wkOrder = asnOrderService.getOne(new LambdaQueryWrapper<WkOrder>().eq(WkOrder::getCode, orderLog.getCode()));
- if (Objects.isNull(wkOrder)) {
+ WkOrder wkOrder = asnOrderMapper.selectOne(new LambdaQueryWrapper<WkOrder>().eq(WkOrder::getCode, orderLog.getCode()));
+ if (!Objects.isNull(wkOrder)) {
throw new CoolException("鏀惰揣鍗曟嵁宸叉坊鍔狅紝鍒锋柊鍚庡啀鎿嶄綔锛侊紒");
}
- if (!asnOrderService.saveOrUpdate(order)) {
+ if (asnOrderMapper.insert(order) <= 0) {
throw new CoolException("鍗曟嵁淇濆瓨澶辫触锛侊紒");
}
List<AsnOrderItemLog> itemLogs = asnOrderItemLogService
.list(new LambdaQueryWrapper<AsnOrderItemLog>()
.eq(AsnOrderItemLog::getLogId, id));
List<WkOrderItem> orderItems = new ArrayList<>();
- if (!Objects.isNull(itemLogs) || !itemLogs.isEmpty()) {
+ if (!Objects.isNull(itemLogs) && !itemLogs.isEmpty()) {
for (AsnOrderItemLog itemLog : itemLogs) {
WkOrderItem item = new WkOrderItem();
BeanUtils.copyProperties(itemLog, item);
item.setId(itemLog.getAsnItemId())
.setOrderId(order.getId())
- .setMatnrId(Long.parseLong(itemLog.getMatnrId()))
+ .setMatnrId(itemLog.getMatnrId())
.setDeleted(0);
orderItems.add(item);
}
@@ -88,4 +99,205 @@
return R.ok();
}
+
+ @Override
+ public boolean save(AsnOrderLog entity) {
+ if (entity == null) {
+ return false;
+ }
+ String tableName = partitionSupport.resolveOrderLogTable(entity.getCreateTime());
+ partitionSupport.ensureTableExists(AsnLogPartitionSupport.ORDER_LOG_TABLE, tableName);
+ return partitionSupport.executeOnTable(AsnLogPartitionSupport.ORDER_LOG_TABLE, tableName, () -> super.save(entity));
+ }
+
+ @Override
+ public boolean saveBatch(Collection<AsnOrderLog> entityList) {
+ return saveBatch(entityList, DEFAULT_BATCH_SIZE);
+ }
+
+ @Override
+ public boolean saveBatch(Collection<AsnOrderLog> entityList, int batchSize) {
+ if (entityList == null || entityList.isEmpty()) {
+ return false;
+ }
+ Map<String, List<AsnOrderLog>> grouped = new LinkedHashMap<>();
+ for (AsnOrderLog entity : entityList) {
+ String tableName = partitionSupport.resolveOrderLogTable(entity == null ? null : entity.getCreateTime());
+ grouped.computeIfAbsent(tableName, key -> new ArrayList<>()).add(entity);
+ }
+ boolean success = true;
+ for (Map.Entry<String, List<AsnOrderLog>> entry : grouped.entrySet()) {
+ partitionSupport.ensureTableExists(AsnLogPartitionSupport.ORDER_LOG_TABLE, entry.getKey());
+ Boolean saved = partitionSupport.executeOnTable(
+ AsnLogPartitionSupport.ORDER_LOG_TABLE,
+ entry.getKey(),
+ () -> super.saveBatch(entry.getValue(), batchSize)
+ );
+ success = success && Boolean.TRUE.equals(saved);
+ }
+ return success;
+ }
+
+ @Override
+ public AsnOrderLog getById(Serializable id) {
+ if (id == null) {
+ return null;
+ }
+ for (String tableName : partitionSupport.listOrderLogTables()) {
+ AsnOrderLog record = partitionSupport.executeOnTable(
+ AsnLogPartitionSupport.ORDER_LOG_TABLE,
+ tableName,
+ () -> baseMapper.selectById(id)
+ );
+ if (record != null) {
+ return record;
+ }
+ }
+ return null;
+ }
+
+ @Override
+ public List<AsnOrderLog> listByIds(Collection<? extends Serializable> idList) {
+ if (idList == null || idList.isEmpty()) {
+ return Collections.emptyList();
+ }
+ Map<Long, AsnOrderLog> merged = new LinkedHashMap<>();
+ for (String tableName : partitionSupport.listOrderLogTables()) {
+ List<AsnOrderLog> part = partitionSupport.executeOnTable(
+ AsnLogPartitionSupport.ORDER_LOG_TABLE,
+ tableName,
+ () -> baseMapper.selectBatchIds(idList)
+ );
+ mergeRecords(merged, part);
+ }
+ return sortRecords(new ArrayList<>(merged.values()));
+ }
+
+ @Override
+ public List<AsnOrderLog> list() {
+ return list((Wrapper<AsnOrderLog>) null);
+ }
+
+ @Override
+ public List<AsnOrderLog> list(Wrapper<AsnOrderLog> queryWrapper) {
+ Map<Long, AsnOrderLog> merged = new LinkedHashMap<>();
+ for (String tableName : partitionSupport.listOrderLogTables()) {
+ List<AsnOrderLog> part = partitionSupport.executeOnTable(
+ AsnLogPartitionSupport.ORDER_LOG_TABLE,
+ tableName,
+ () -> baseMapper.selectList(queryWrapper)
+ );
+ mergeRecords(merged, part);
+ }
+ return sortRecords(new ArrayList<>(merged.values()));
+ }
+
+ @Override
+ public AsnOrderLog getOne(Wrapper<AsnOrderLog> queryWrapper) {
+ List<AsnOrderLog> records = list(queryWrapper);
+ return records.isEmpty() ? null : records.get(0);
+ }
+
+ @Override
+ public <E extends IPage<AsnOrderLog>> E page(E page, Wrapper<AsnOrderLog> queryWrapper) {
+ List<AsnOrderLog> records = list(queryWrapper);
+ long current = page.getCurrent() <= 0 ? 1L : page.getCurrent();
+ long size = page.getSize() <= 0 ? records.size() : page.getSize();
+ int fromIndex = (int) Math.min((current - 1) * size, records.size());
+ int toIndex = (int) Math.min(fromIndex + size, records.size());
+ page.setTotal(records.size());
+ page.setRecords(fromIndex >= records.size() ? Collections.emptyList() : new ArrayList<>(records.subList(fromIndex, toIndex)));
+ return page;
+ }
+
+ @Override
+ public boolean updateById(AsnOrderLog entity) {
+ if (entity == null || entity.getId() == null) {
+ return false;
+ }
+ String tableName = locateTableById(entity.getId());
+ if (tableName == null) {
+ return false;
+ }
+ return partitionSupport.executeOnTable(
+ AsnLogPartitionSupport.ORDER_LOG_TABLE,
+ tableName,
+ () -> super.updateById(entity)
+ );
+ }
+
+ @Override
+ public boolean removeById(Serializable id) {
+ if (id == null) {
+ return false;
+ }
+ String tableName = locateTableById(id);
+ if (tableName == null) {
+ return false;
+ }
+ return partitionSupport.executeOnTable(
+ AsnLogPartitionSupport.ORDER_LOG_TABLE,
+ tableName,
+ () -> super.removeById(id)
+ );
+ }
+
+ @Override
+ public boolean removeByIds(Collection<?> list) {
+ if (list == null || list.isEmpty()) {
+ return false;
+ }
+ Map<String, List<Serializable>> groupedIds = new LinkedHashMap<>();
+ for (Object idObj : list) {
+ if (!(idObj instanceof Serializable)) {
+ continue;
+ }
+ Serializable id = (Serializable) idObj;
+ String tableName = locateTableById(id);
+ if (tableName != null) {
+ groupedIds.computeIfAbsent(tableName, key -> new ArrayList<>()).add(id);
+ }
+ }
+ boolean removed = false;
+ for (Map.Entry<String, List<Serializable>> entry : groupedIds.entrySet()) {
+ Boolean partRemoved = partitionSupport.executeOnTable(
+ AsnLogPartitionSupport.ORDER_LOG_TABLE,
+ entry.getKey(),
+ () -> super.removeByIds(entry.getValue())
+ );
+ removed = removed || Boolean.TRUE.equals(partRemoved);
+ }
+ return removed;
+ }
+
+ private String locateTableById(Serializable id) {
+ for (String tableName : partitionSupport.listOrderLogTables()) {
+ AsnOrderLog record = partitionSupport.executeOnTable(
+ AsnLogPartitionSupport.ORDER_LOG_TABLE,
+ tableName,
+ () -> baseMapper.selectById(id)
+ );
+ if (record != null) {
+ return tableName;
+ }
+ }
+ return null;
+ }
+
+ private void mergeRecords(Map<Long, AsnOrderLog> merged, List<AsnOrderLog> records) {
+ if (records == null || records.isEmpty()) {
+ return;
+ }
+ for (AsnOrderLog record : records) {
+ if (record == null || record.getId() == null) {
+ continue;
+ }
+ merged.putIfAbsent(record.getId(), record);
+ }
+ }
+
+ private List<AsnOrderLog> sortRecords(List<AsnOrderLog> records) {
+ records.sort(Comparator.comparing(AsnOrderLog::getId, Comparator.nullsLast(Long::compareTo)).reversed());
+ return records;
+ }
}
--
Gitblit v1.9.1