Commit ccd1dfaa by zhangtw

新增批量入库功能

parent 7896e6a3
......@@ -18,29 +18,6 @@
<i class="el-icon-upload"></i>
<div class="el-upload__text">将文件拖到此处,或<em>点击上传</em></div>
<div class="el-upload__tip text-center" slot="tip">
<div
class="order-type-radio"
v-if="showTrdcCheckbox && dict.type.inbound_outbound_type.length"
style="margin-bottom: 8px; text-align: left; padding-left: 20px;"
>
<el-radio-group v-model="upload.orderType">
<el-radio
v-for="item in dict.type.inbound_outbound_type"
:key="item.value"
:label="item.value"
style="margin-right: 20px;"
>
{{ item.label }}
</el-radio>
</el-radio-group>
</div>
<!-- 加载中提示 -->
<div
v-else-if="showTrdcCheckbox && !dict.type.inbound_outbound_type.length"
style="margin-bottom: 8px; text-align: left; padding-left: 20px;"
>
<i class="el-icon-loading" style="font-size: 14px;"></i> 加载入库类型...
</div>
<!-- <div class="el-upload__tip" slot="tip">
<el-checkbox v-model="upload.updateSupport" />是否更新已经存在的数据
</div> -->
......
......@@ -293,7 +293,7 @@ public class InboundOrdersController extends BaseController
}
// 3. 通用导入逻辑(抽取重复代码,避免冗余)
String message = handleImport(getVOClassByOrderType(orderType), file, headerList, updateSupport, getUsername(), orderType);
String message = handleImport(InboundTemplateVO.class, file, headerList, updateSupport, getUsername(), orderType);
return success(message);
}
......@@ -309,6 +309,7 @@ public class InboundOrdersController extends BaseController
}
}
private static final Map<Class<?>, List<String>> REQUIRED_HEADS_CACHE = new ConcurrentHashMap<>();
/**
* 通用导入逻辑(泛型适配不同VO)
*/
......
......@@ -68,11 +68,11 @@ public class InboundTemplateVO extends BaseEntity {
private String warehouseId;
/** 备注 */
// @Excel(name = "备注")
@Excel(name = "备注")
private String remark;
/** 库位ID 检索条件 */
@Excel(name = "收货库位")
// @Excel(name = "收货库位")
private String remark2;
/** 标签颜色 字典,检索条件 */
......
......@@ -297,7 +297,7 @@ public class InboundOrdersServiceImpl implements IInboundOrdersService
InboundOrders mainDO = null;
List<InboundOrderItems> itemDOList = new ArrayList<>();
List<Inventory> inventoryList = new ArrayList<>();
// List<Inventory> inventoryList = new ArrayList<>();
try {
// 4.1 处理主表(每个入库单号只处理一次主表)
T firstVO = voList.get(0); // 取第一条VO的主表信息
......@@ -336,6 +336,7 @@ public class InboundOrdersServiceImpl implements IInboundOrdersService
"plannedPackages", "materialUnit", "materialRemark"); // 排除子表字段
// 填充主表必填字段
mainDO.setId(UUID.randomUUID().toString());
mainDO.setOrderTypeId(mainDO.getOrderType());
mainDO.setInboundDate(now);
mainDO.setOrderId(orderId);
mainDO.setCreateBy(operId);
......@@ -343,13 +344,13 @@ public class InboundOrdersServiceImpl implements IInboundOrdersService
mainDO.setCreateUserCode(operId);
mainDO.setIsImport(1);
mainDO.setIsUsed(1L);
mainDO.setOrderTypeId(Optional.ofNullable(orderType).map(String::valueOf).orElse(""));
// mainDO.setOrderTypeId(Optional.ofNullable(orderType).map(String::valueOf).orElse(""));
// 设置默认值
if (mainDO.getSortNo() == null) {
mainDO.setSortNo(0L);
}
if (mainDO.getOrderStatus() == null) {
mainDO.setOrderStatus(2L); // 默认草稿状态
mainDO.setOrderStatus(1L); // 默认草稿状态
}
// ========== 货主查询(反射获取ownerId) ==========
......@@ -488,21 +489,21 @@ public class InboundOrdersServiceImpl implements IInboundOrdersService
log.error("导入明细失败-入库单【{}】-SAP【{}】,实发数量和实际件数为空", orderId, sapNo, e);
throw new ServiceException("实发数量和实际件数为空");
}
Inventory inventoryDO = new Inventory(
Long.parseLong(mainDO.getOrderTypeId()),
orderId,
itemDO.getMaterialId(),
batchId,
itemDO.getWarehouseId(),
itemDO.getLocationId(),
mainDO.getOwnerId(),
itemDO.getActualQuantity() == null ? 0L : itemDO.getActualQuantity(),
unitWeight,
1L,
itemDO.getUnitPrice()
);
inventoryList.add(inventoryDO);
//
// Inventory inventoryDO = new Inventory(
// Long.parseLong(mainDO.getOrderTypeId()),
// orderId,
// itemDO.getMaterialId(),
// batchId,
// itemDO.getWarehouseId(),
// itemDO.getLocationId(),
// mainDO.getOwnerId(),
// itemDO.getActualQuantity() == null ? 0L : itemDO.getActualQuantity(),
// unitWeight,
// 1L,
// itemDO.getUnitPrice()
// );
// inventoryList.add(inventoryDO);
} catch (Exception e) {
// 单个明细失败:仅统计,不影响整单
totalItemFailure++;
......@@ -525,8 +526,8 @@ public class InboundOrdersServiceImpl implements IInboundOrdersService
// 4.3 批量插入明细
if (!CollectionUtils.isEmpty(itemDOList)) {
int itemSuccess = inboundOrdersMapper.batchInboundOrderItems(itemDOList);
int inventorySuccess = iInventoryService.insertInventoryList(inventoryList);
if (itemSuccess != itemDOList.size() && itemSuccess != inventorySuccess) {
// int inventorySuccess = iInventoryService.insertInventoryList(inventoryList);
if (itemSuccess != itemDOList.size()) {
// 批量插入部分失败,主动回滚事务
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
throw new ServiceException("明细批量插入失败,成功" + itemSuccess + "条,总" + itemDOList.size() + "条");
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论