chen.lin
昨天 d3f479a5e246d808688f85ca0b59e86c92621dbf
标签浮点处理
2个文件已修改
141 ■■■■■ 已修改文件
rsf-admin/src/layout/TabsBar.jsx 124 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
rsf-server/src/main/java/com/vincent/rsf/server/manager/service/impl/OutStockServiceImpl.java 17 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
rsf-admin/src/layout/TabsBar.jsx
@@ -275,47 +275,47 @@
        setContextMenuTab(null);
    };
    // 关闭左侧标签页(保留指定标签页及其右侧的所有标签页)
    // const handleCloseLeft = (keepTabPath) => {
    //     const keepTabIndex = tabs.findIndex(tab => tab.path === keepTabPath);
    //     if (keepTabIndex < 0) {
    //         return;
    //     }
    //关闭左侧标签页(保留指定标签页及其右侧的所有标签页)
    const handleCloseLeft = (keepTabPath) => {
        const keepTabIndex = tabs.findIndex(tab => tab.path === keepTabPath);
        if (keepTabIndex < 0) {
            return;
        }
    //     // 保留指定标签页及其右侧的所有标签页
    //     const newTabs = tabs.slice(keepTabIndex);
        // 保留指定标签页及其右侧的所有标签页
        const newTabs = tabs.slice(keepTabIndex);
    //     // 确保dashboard始终在第一位(如果存在)
    //     const dashboardTab = newTabs.find(tab => tab.path === '/dashboard');
    //     if (dashboardTab && newTabs[0].path !== '/dashboard') {
    //         const dashboardIndex = newTabs.findIndex(tab => tab.path === '/dashboard');
    //         if (dashboardIndex > 0) {
    //             newTabs.splice(dashboardIndex, 1);
    //             newTabs.unshift(dashboardTab);
    //         }
    //     }
        // 确保dashboard始终在第一位(如果存在)
        const dashboardTab = newTabs.find(tab => tab.path === '/dashboard');
        if (dashboardTab && newTabs[0].path !== '/dashboard') {
            const dashboardIndex = newTabs.findIndex(tab => tab.path === '/dashboard');
            if (dashboardIndex > 0) {
                newTabs.splice(dashboardIndex, 1);
                newTabs.unshift(dashboardTab);
            }
        }
    //     saveTabs(newTabs);
    //     setTabs(newTabs);
    //     setContextMenu(null);
    //     setContextMenuTab(null);
    // };
        saveTabs(newTabs);
        setTabs(newTabs);
        setContextMenu(null);
        setContextMenuTab(null);
    };
    // 关闭右侧标签页(保留指定标签页及其左侧的所有标签页)
    // const handleCloseRight = (keepTabPath) => {
    //     const keepTabIndex = tabs.findIndex(tab => tab.path === keepTabPath);
    //     if (keepTabIndex < 0) {
    //         return;
    //     }
    const handleCloseRight = (keepTabPath) => {
        const keepTabIndex = tabs.findIndex(tab => tab.path === keepTabPath);
        if (keepTabIndex < 0) {
            return;
        }
    //     // 保留指定标签页及其左侧的所有标签页
    //     const newTabs = tabs.slice(0, keepTabIndex + 1);
        // 保留指定标签页及其左侧的所有标签页
        const newTabs = tabs.slice(0, keepTabIndex + 1);
    //     saveTabs(newTabs);
    //     setTabs(newTabs);
    //     setContextMenu(null);
    //     setContextMenuTab(null);
    // };
        saveTabs(newTabs);
        setTabs(newTabs);
        setContextMenu(null);
        setContextMenuTab(null);
    };
    // 处理右键菜单
    const handleContextMenu = (event, tab) => {
@@ -373,18 +373,18 @@
    };
    // 右键菜单:关闭左侧标签
    // const handleCloseLeftTabs = () => {
    //     if (contextMenuTab) {
    //         handleCloseLeft(contextMenuTab.path);
    //     }
    // };
    const handleCloseLeftTabs = () => {
        if (contextMenuTab) {
            handleCloseLeft(contextMenuTab.path);
        }
    };
    // 右键菜单:关闭右侧标签
    // const handleCloseRightTabs = () => {
    //     if (contextMenuTab) {
    //         handleCloseRight(contextMenuTab.path);
    //     }
    // };
    const handleCloseRightTabs = () => {
        if (contextMenuTab) {
            handleCloseRight(contextMenuTab.path);
        }
    };
    // 获取当前标签页索引
@@ -549,13 +549,33 @@
                        ? { top: contextMenu.mouseY, left: contextMenu.mouseX }
                        : undefined
                }
                PaperProps={{
                    sx: {
                        minWidth: 120,
                        borderRadius: '8px',
                        boxShadow: '0 4px 20px rgba(0,0,0,0.08)',
                        mt: 0.5,
                        py: 0.5,
                    },
                }}
                MenuListProps={{
                    sx: { py: 0 },
                }}
            >
                {contextMenuTab && contextMenuTab.closable && (
                    <MenuItem onClick={handleCloseCurrentTab}>
                    <MenuItem
                        onClick={handleCloseCurrentTab}
                        sx={{
                            fontSize: '0.8125rem',
                            py: 0.75,
                            px: 1.5,
                            minHeight: 'auto',
                        }}
                    >
                        {t('ra.action.close', '关闭当前标签')}
                    </MenuItem>
                )}
                {/* {contextMenuTab && canCloseLeftForTab(contextMenuTab.path) && (
                {contextMenuTab && canCloseLeftForTab(contextMenuTab.path) && (
                    <MenuItem onClick={handleCloseLeftTabs}>
                        {t('ra.action.closeLeft', '关闭左侧标签')}
                    </MenuItem>
@@ -564,9 +584,17 @@
                    <MenuItem onClick={handleCloseRightTabs}>
                        {t('ra.action.closeRight', '关闭右侧标签')}
                    </MenuItem>
                )} */}
                )}
                {contextMenuTab && canCloseOthersForTab(contextMenuTab.path) && (
                    <MenuItem onClick={handleCloseOtherTabs}>
                    <MenuItem
                        onClick={handleCloseOtherTabs}
                        sx={{
                            fontSize: '0.8125rem',
                            py: 0.75,
                            px: 1.5,
                            minHeight: 'auto',
                        }}
                    >
                        {t('ra.action.closeOthers', '关闭其他标签')}
                    </MenuItem>
                )}
rsf-server/src/main/java/com/vincent/rsf/server/manager/service/impl/OutStockServiceImpl.java
@@ -29,6 +29,7 @@
import org.springframework.transaction.annotation.Transactional;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.*;
import java.util.stream.Collectors;
@@ -47,6 +48,8 @@
    public Logger logger = LoggerFactory.getLogger(this.getClass());
    /** 出库剩余量容差:小于等于此值视为已分配完,避免浮点误差产生多余“库存不足”行 */
    private static final BigDecimal ISSUED_TOLERANCE = new BigDecimal("0.000001");
    @Autowired
    private AsnOrderItemService asnOrderItemService;
@@ -681,9 +684,8 @@
        Set<ExistDto> existDtos = new HashSet<>();
        for (WkOrderItem wkOrderItem : wkOrderItems) {
            BigDecimal issued = new BigDecimal(wkOrderItem.getAnfme().toString())
                    .subtract(new BigDecimal(wkOrderItem.getWorkQty().toString())
                    );
            if (issued.doubleValue() <= 0) {
                    .subtract(new BigDecimal(wkOrderItem.getWorkQty().toString()));
            if (issued.compareTo(ISSUED_TOLERANCE) <= 0) {
                continue;
            }
            List<LocItem> locItems = new ArrayList<>();
@@ -697,7 +699,7 @@
            for (LocItem locItem : locItems) {
                Loc loc = locService.getById(locItem.getLocId());
                List<LocItem> itemList = locItemService.list(new LambdaQueryWrapper<LocItem>().eq(LocItem::getLocCode, locItem.getLocCode()));
                if (issued.doubleValue() > 0) {
                if (issued.compareTo(ISSUED_TOLERANCE) > 0) {
                    ExistDto existDto = new ExistDto().setBatch(locItem.getBatch()).setMatnr(locItem.getMatnrCode()).setLocNo(locItem.getLocCode());
                    if (existDtos.add(existDto)) {
                        locItem.setOutQty(issued.doubleValue() >= locItem.getAnfme() ? locItem.getAnfme() : issued.doubleValue());
@@ -730,14 +732,15 @@
                    }
                }
            }
            if (issued.doubleValue() > 0) {
            if (issued.compareTo(ISSUED_TOLERANCE) > 0) {
                double remaining = issued.setScale(6, RoundingMode.HALF_UP).doubleValue();
                LocItem locItem = new LocItem()
                        .setId(new Random().nextLong())
                        .setMatnrCode(wkOrderItem.getMatnrCode())
                        .setMaktx(wkOrderItem.getMaktx())
                        .setAnfme(0.00)
                        .setWorkQty(issued.doubleValue())
                        .setOutQty(issued.doubleValue())
                        .setWorkQty(remaining)
                        .setOutQty(remaining)
                        .setUnit(wkOrderItem.getStockUnit())
                        .setBatch(wkOrderItem.getSplrBatch());
                OrderOutItemDto orderOutItemDto = new OrderOutItemDto();