skyouc
3 天以前 4592353d65d7b5e8477d9cad0bd2836bf7792186
代码优化
波次功能优化
3个文件已修改
1个文件已添加
237 ■■■■■ 已修改文件
rsf-admin/src/i18n/zh.js 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
rsf-admin/src/page/orders/wave/WaveList.jsx 73 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
rsf-server/src/main/java/com/vincent/rsf/server/manager/schedules/PakinSchedules.java 94 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
rsf-server/src/main/java/com/vincent/rsf/server/manager/schedules/ScheduleJobs.java 68 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
rsf-admin/src/i18n/zh.js
@@ -866,7 +866,7 @@
            wave: {
                code: "波次号",
                type: "单据类型",
                exceStatus: "状态",
                exceStatus: "执行状态",
                anfme: "数量",
                groupQty: '品类数',
                qty: "完成数量",
rsf-admin/src/page/orders/wave/WaveList.jsx
@@ -23,6 +23,7 @@
    NumberInput,
    useRefresh,
    useRedirect,
    AutocompleteInput,
    Button,
} from 'react-admin';
import { PAGE_DRAWER_WIDTH, OPERATE_MODE, DEFAULT_PAGE_SIZE, DEFAULT_WAVE_AUTO_EXCE } from '@/config/setting';
@@ -54,39 +55,7 @@
    },
}));
const filters = [
    <SearchInput source="condition" alwaysOn />,
    <DateInput label='common.time.after' source="timeStart" alwaysOn />,
    <DateInput label='common.time.before' source="timeEnd" alwaysOn />,
    <TextInput source="code" label="table.field.wave.code" />,
    <SelectInput source="type" label="table.field.wave.type"
        choices={[
            { id: 0, name: '手动' },
            { id: 1, name: '自动' },
        ]}
    />,
    <SelectInput source="exceStatus" label="table.field.wave.exceStatus"
        choices={[
            { id: 0, name: '初始化' },
            { id: 1, name: '生成任务' },
            { id: 2, name: '任务播种' },
            { id: 3, name: '完成' },
        ]}
    />,
    <NumberInput source="anfme" label="table.field.wave.anfme" />,
    <NumberInput source="qty" label="table.field.wave.qty" />,
    <NumberInput source="orderNum" label="table.field.wave.orderNum" />,
    <TextInput label="common.field.memo" source="memo" />,
    <SelectInput
        label="common.field.status"
        source="status"
        choices={[
            { id: '1', name: 'common.enums.statusTrue' },
            { id: '0', name: 'common.enums.statusFalse' },
        ]}
        resettable
    />,
]
const WaveList = () => {
    const translate = useTranslate();
@@ -95,6 +64,44 @@
    const [detailDialog, setDetailDialog] = useState(false);
    const [select, setSelectIds] = useState({});
    const [drawerVal, setDrawerVal] = useState(false);
    const dicts = JSON.parse(localStorage.getItem('sys_dicts'))?.filter(dict => (dict.dictTypeCode == 'sys_wave_exce_status')) || [];
    const filters = [
        <SearchInput source="condition" alwaysOn />,
        <DateInput label='common.time.after' source="timeStart" alwaysOn />,
        <DateInput label='common.time.before' source="timeEnd" alwaysOn />,
        <TextInput source="code" label="table.field.wave.code" />,
        <AutocompleteInput
            choices={dicts}
            optionText="label"
            label="table.field.wave.exceStatus"
            source="exceStatus"
            format={value => value || '0'}
            optionValue="value"
            parse={v => v}
            alwaysOn
        />,
        <SelectInput source="type" label="table.field.wave.type"
            choices={[
                { id: 0, name: '手动' },
                { id: 1, name: '自动' },
            ]}
        />,
        <NumberInput source="anfme" label="table.field.wave.anfme" />,
        <NumberInput source="qty" label="table.field.wave.qty" />,
        <NumberInput source="orderNum" label="table.field.wave.orderNum" />,
        <TextInput label="common.field.memo" source="memo" />,
        <SelectInput
            label="common.field.status"
            source="status"
            choices={[
                { id: '1', name: 'common.enums.statusTrue' },
                { id: '0', name: 'common.enums.statusFalse' },
            ]}
            resettable
        />,
    ]
    useEffect(() => {
        getConfig()
rsf-server/src/main/java/com/vincent/rsf/server/manager/schedules/PakinSchedules.java
New file
@@ -0,0 +1,94 @@
package com.vincent.rsf.server.manager.schedules;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.vincent.rsf.framework.exception.CoolException;
import com.vincent.rsf.server.manager.entity.WaitPakin;
import com.vincent.rsf.server.manager.entity.WaitPakinItem;
import com.vincent.rsf.server.manager.entity.WaitPakinItemLog;
import com.vincent.rsf.server.manager.entity.WaitPakinLog;
import com.vincent.rsf.server.manager.enums.PakinIOStatus;
import com.vincent.rsf.server.manager.service.WaitPakinItemLogService;
import com.vincent.rsf.server.manager.service.WaitPakinItemService;
import com.vincent.rsf.server.manager.service.WaitPakinLogService;
import com.vincent.rsf.server.manager.service.WaitPakinService;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
@Component
public class PakinSchedules {
    @Autowired
    private WaitPakinService waitPakinService;
    @Autowired
    private WaitPakinItemService waitPakinItemService;
    @Autowired
    private WaitPakinLogService waitPakinLogService;
    @Autowired
    private WaitPakinItemLogService waitPakinItemLogService;
    /**
     * @param
     * @return
     * @author Ryan
     * @description 组拖历史档
     * @time 2025/3/29 12:36
     */
    @Scheduled(cron = "0/25 * * * * ?")
    @Transactional(rollbackFor = Exception.class)
    public void pakinLog() {
        List<WaitPakin> pakinIds = waitPakinService.list(new LambdaQueryWrapper<WaitPakin>()
                .eq(WaitPakin::getIoStatus, PakinIOStatus.PAKIN_IO_STATUS_TASK_DONE.val)
                .select(WaitPakin::getId));
        if (pakinIds.isEmpty()) {
            return;
        }
        List<Long> list = pakinIds.stream().map(WaitPakin::getId).collect(Collectors.toList());
        List<WaitPakin> pakins = waitPakinService.list(new LambdaQueryWrapper<WaitPakin>().in(WaitPakin::getId, list));
        if (pakins.isEmpty()) {
            throw new CoolException("组拖单为空!!");
        }
        pakins.forEach(pakin -> {
            WaitPakinLog log = new WaitPakinLog();
            BeanUtils.copyProperties(pakin, log);
            log.setPakinId(pakin.getId()).setIoStatus(PakinIOStatus.PAKIN_IO_STATUS_TASK_DONE.val);
            if (!waitPakinLogService.save(log)) {
                throw new CoolException("组托日志保存失败!!");
            }
            List<WaitPakinItem> pakinItems = waitPakinItemService.list(new LambdaQueryWrapper<WaitPakinItem>().in(WaitPakinItem::getPakinId, pakin.getId()));
            if (pakinItems.isEmpty()) {
                throw new CoolException("组拖明细为空!!");
            }
            List<WaitPakinItemLog> itemLogs = new ArrayList<>();
            pakinItems.forEach(item -> {
                WaitPakinItemLog itemLog = new WaitPakinItemLog();
                BeanUtils.copyProperties(item, itemLog);
                itemLog.setPakinItemId(item.getId())
                        .setLogId(log.getId())
                        .setQty(item.getWorkQty())
                        .setWorkQty(0.0)
                        .setPakinId(item.getPakinId());
                itemLogs.add(itemLog);
            });
            if (!waitPakinItemLogService.saveBatch(itemLogs)) {
                throw new CoolException("历史明细档保存失败!!");
            }
        });
        if (!waitPakinService.removeByIds(list)) {
            throw new CoolException("原单据删除失败!!");
        }
        if (!waitPakinItemService.remove(new LambdaQueryWrapper<WaitPakinItem>().in(WaitPakinItem::getPakinId, list))) {
            throw new CoolException("原单据明细删除失败!!");
        }
    }
}
rsf-server/src/main/java/com/vincent/rsf/server/manager/schedules/ScheduleJobs.java
@@ -58,14 +58,6 @@
    @Resource
    private SysStockProperties flowProperties;
    @Autowired
    private WaitPakinService waitPakinService;
    @Autowired
    private WaitPakinItemService waitPakinItemService;
    @Autowired
    private WaitPakinLogService waitPakinLogService;
    @Autowired
    private WaitPakinItemLogService waitPakinItemLogService;
    @Autowired
    private ConfigService configService;
    @Autowired
    private WarehouseAreasService warehouseAreasService;
@@ -318,64 +310,4 @@
            throw new CoolException("生成编码失败!!");
        }
    }
    /**
     * @param
     * @return
     * @author Ryan
     * @description 组拖历史档
     * @time 2025/3/29 12:36
     */
    @Scheduled(cron = "0/25 * * * * ?")
    @Transactional(rollbackFor = Exception.class)
    public void pakinLog() {
        List<WaitPakin> pakinIds = waitPakinService.list(new LambdaQueryWrapper<WaitPakin>()
                .eq(WaitPakin::getIoStatus, PakinIOStatus.PAKIN_IO_STATUS_TASK_DONE.val)
                .select(WaitPakin::getId));
        if (pakinIds.isEmpty()) {
            return;
        }
        List<Long> list = pakinIds.stream().map(WaitPakin::getId).collect(Collectors.toList());
        List<WaitPakin> pakins = waitPakinService.list(new LambdaQueryWrapper<WaitPakin>().in(WaitPakin::getId, list));
        if (pakins.isEmpty()) {
            throw new CoolException("组拖单为空!!");
        }
        pakins.forEach(pakin -> {
            WaitPakinLog log = new WaitPakinLog();
            BeanUtils.copyProperties(pakin, log);
            log.setPakinId(pakin.getId()).setIoStatus(PakinIOStatus.PAKIN_IO_STATUS_TASK_DONE.val);
            if (!waitPakinLogService.save(log)) {
                throw new CoolException("组托日志保存失败!!");
            }
            List<WaitPakinItem> pakinItems = waitPakinItemService.list(new LambdaQueryWrapper<WaitPakinItem>().in(WaitPakinItem::getPakinId, pakin.getId()));
            if (pakinItems.isEmpty()) {
                throw new CoolException("组拖明细为空!!");
            }
            List<WaitPakinItemLog> itemLogs = new ArrayList<>();
            pakinItems.forEach(item -> {
                WaitPakinItemLog itemLog = new WaitPakinItemLog();
                BeanUtils.copyProperties(item, itemLog);
                itemLog.setPakinItemId(item.getId())
                        .setLogId(log.getId())
                        .setQty(item.getWorkQty())
                        .setWorkQty(0.0)
                        .setPakinId(item.getPakinId());
                itemLogs.add(itemLog);
            });
            if (!waitPakinItemLogService.saveBatch(itemLogs)) {
                throw new CoolException("历史明细档保存失败!!");
            }
        });
        if (!waitPakinService.removeByIds(list)) {
            throw new CoolException("原单据删除失败!!");
        }
        if (!waitPakinItemService.remove(new LambdaQueryWrapper<WaitPakinItem>().in(WaitPakinItem::getPakinId, list))) {
            throw new CoolException("原单据明细删除失败!!");
        }
    }
}