skyouc
11 小时以前 0b2e709d64339f06b4ede5ef1c8f17345aa8e653
波次自动下发功能 优化
7个文件已修改
1个文件已添加
145 ■■■■■ 已修改文件
rsf-admin/.env 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
rsf-admin/src/i18n/en.js 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
rsf-admin/src/page/orders/wave/WaveItemList.jsx 28 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
rsf-server/src/main/java/com/vincent/rsf/server/manager/controller/WaveController.java 3 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
rsf-server/src/main/java/com/vincent/rsf/server/manager/controller/WaveItemController.java 24 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
rsf-server/src/main/java/com/vincent/rsf/server/manager/enums/WaveItemExceStatus.java 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
rsf-server/src/main/java/com/vincent/rsf/server/manager/schedules/WaveSchedules.java 84 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
rsf-server/src/main/java/com/vincent/rsf/server/system/constant/GlobalConfigCode.java 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
rsf-admin/.env
@@ -1,3 +1,3 @@
VITE_BASE_IP=192.168.4.50
VITE_BASE_IP=192.168.4.16
# VITE_BASE_IP=47.76.147.249
VITE_BASE_PORT=8080
rsf-admin/src/i18n/en.js
@@ -1171,6 +1171,7 @@
        poCreate: "Create By PO",
        createTask: "createTask",
        publicWorking: 'Public Working',
        continuePub: 'Continue Public',
        recover: "recover",
        createWave: "Create Wave",
        order: 'Orders',
rsf-admin/src/page/orders/wave/WaveItemList.jsx
@@ -152,6 +152,7 @@
                    <TextField source="memo" label="common.field.memo" sortable={false} />
                    <WrapperField cellClassName="opt" label="common.field.opt">
                        <BulkPauseButton />
                        <ContinueButton />
                    </WrapperField>
                </StyledDatagrid>
            </List>
@@ -211,11 +212,34 @@
const BulkPauseButton = () => {
    const { data, selectedIds, onUnselectItems } = useListContext();
    const notify = useNotify()
    const record = useRecordContext();
    const pauseClick = () => {
        onUnselectItems();
    const pauseClick = async () => {
        const { data: { code, data, msg } } = await request.post('/waveItem/pause/pub', { wave: waveId, waveItem: selectedIds });
        if (code === 200) {
            notify(msg);
        } else {
            notify(msg);
        }
    }
    return (
        record?.exceStatus == 1 ? <Button label="toolbar.pause" onClick={pauseClick} startIcon={<PauseCircleOutlineIcon />} /> : <></>
    )
}
const ContinueButton = () => {
    const { data, selectedIds, onUnselectItems } = useListContext();
    const notify = useNotify()
    const record = useRecordContext();
    const continueClick = async () => {
        const { data: { code, data, msg } } = await request.post('/waveItem/continue/pub', { wave: waveId, waveItem: selectedIds });
        if (code === 200) {
            notify(msg);
        } else {
            notify(msg);
        }
    }
    return (
        record?.exceStatus == 4 ? <Button label="toolbar.continuePub" onClick={continueClick} startIcon={<PauseCircleOutlineIcon />} /> : <></>
    )
}
rsf-server/src/main/java/com/vincent/rsf/server/manager/controller/WaveController.java
@@ -154,4 +154,7 @@
        return R.ok().add(pageResult);
    }
}
rsf-server/src/main/java/com/vincent/rsf/server/manager/controller/WaveItemController.java
@@ -1,6 +1,7 @@
package com.vincent.rsf.server.manager.controller;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.vincent.rsf.framework.common.Cools;
import com.vincent.rsf.framework.common.R;
@@ -10,8 +11,10 @@
import com.vincent.rsf.server.common.domain.KeyValVo;
import com.vincent.rsf.server.common.domain.PageParam;
import com.vincent.rsf.server.manager.entity.WaveItem;
import com.vincent.rsf.server.manager.enums.WaveItemExceStatus;
import com.vincent.rsf.server.manager.service.WaveItemService;
import com.vincent.rsf.server.system.controller.BaseController;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
@@ -107,4 +110,25 @@
        ExcelUtil.build(ExcelUtil.create(waveItemService.list(), WaveItem.class), response);
    }
    @PreAuthorize("hasAuthority('manager:waveItem:update')")
    @ApiOperation("暂停下发任务")
    @PostMapping("/waveItem/pause/pub")
    public R pausePublicTask(@PathVariable Long id) {
         waveItemService.update(new LambdaUpdateWrapper<WaveItem>()
                 .eq(WaveItem::getId, id)
                 .set(WaveItem::getExceStatus, WaveItemExceStatus.WAVE_ITEM_EXCE_PAUSE.val));
         return R.ok();
    }
    @PreAuthorize("hasAuthority('manager:waveItem:update')")
    @ApiOperation("继续下发任务")
    @PostMapping("/waveItem/continue/pub")
    public R continuePublicTask(@PathVariable Long id) {
        waveItemService.update(new LambdaUpdateWrapper<WaveItem>()
                .eq(WaveItem::getId, id)
                .set(WaveItem::getExceStatus, WaveItemExceStatus.WAVE_ITEM_EXCE_STATUS_UN.val));
        return R.ok();
    }
}
rsf-server/src/main/java/com/vincent/rsf/server/manager/enums/WaveItemExceStatus.java
@@ -14,6 +14,7 @@
    WAVE_ITEM_EXCE_STATUS_UN("0", "未执行"),
    WAVE_EXCE_STATUS_ING("1", "执行中"),
    WAVE_EXCE_STATUS_SEED("2", "已下发"),
    WAVE_ITEM_EXCE_PAUSE("4", "暂停"),
    WAVE_EXCE_STATUS_DONE("3", "下发完成"),
    ;
rsf-server/src/main/java/com/vincent/rsf/server/manager/schedules/WaveSchedules.java
New file
@@ -0,0 +1,84 @@
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.common.constant.Constants;
import com.vincent.rsf.server.manager.entity.Wave;
import com.vincent.rsf.server.manager.entity.WaveItem;
import com.vincent.rsf.server.manager.enums.WaveExceStatus;
import com.vincent.rsf.server.manager.enums.WaveItemExceStatus;
import com.vincent.rsf.server.manager.service.WaveItemService;
import com.vincent.rsf.server.manager.service.WaveService;
import com.vincent.rsf.server.system.constant.GlobalConfigCode;
import com.vincent.rsf.server.system.entity.Config;
import com.vincent.rsf.server.system.service.ConfigService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.stream.Collectors;
/**
* @author Ryan
* @description 波次定时任务
* @param
* @return
* @time 2025/6/23 13:49
*/
@Component
public class WaveSchedules {
    @Autowired
    private WaveService waveService;
    @Autowired
    private WaveItemService waveItemService;
    @Autowired
    private ConfigService configService;
    /**
    * @author Ryan
    * @description 自动下发波次任务
    * @param
    * @return
    * @time 2025/6/23 13:52
    */
    @Scheduled(cron = "0/15 * * * * ?")
    public void autoGenerateTask() {
        Config config = configService.getOne(new LambdaQueryWrapper<Config>().eq(Config::getFlag, GlobalConfigCode.WAVE_AUTO_EXCE_TASK));
        if (Objects.isNull(config) || !Boolean.parseBoolean(config.getVal())) {
            return;
        }
        List<Wave> list = waveService.list(new LambdaQueryWrapper<Wave>()
                        .select(Wave::getId)
                .eq(Wave::getExceStatus, WaveExceStatus.WAVE_EXCE_STATUS_INIT.val));
        if (list.isEmpty()) {
            return;
        }
        List<Long> longs = list.stream().map(Wave::getId).collect(Collectors.toList());
        List<WaveItem> waveItems = waveItemService.list(new LambdaQueryWrapper<WaveItem>()
                .in(WaveItem::getId, longs)
                .eq(WaveItem::getExceStatus, WaveItemExceStatus.WAVE_ITEM_EXCE_STATUS_UN.val)
        );
        if (waveItems.isEmpty()) {
            return;
        }
        Map<Long, List<WaveItem>> listMap = waveItems.stream().collect(Collectors.groupingBy(WaveItem::getWaveId));
        listMap.keySet().forEach(waveId -> {
            Map<String, Object> params = new HashMap<>();
            params.put("wave", waveId);
            params.put("waveItems", waveItems);
            waveService.waveToTask(params, waveId);
        });
    }
}
rsf-server/src/main/java/com/vincent/rsf/server/system/constant/GlobalConfigCode.java
@@ -16,5 +16,7 @@
    public final static String ALLOW_OVER_CHANGE = "AllowOverchange";
    /**订单是否上报平台*/
    public final static String ORDER_INOF_REPORT_PLAT = "OrderInofReportPlat";
    /**波次自动下发任务*/
    public final static String WAVE_AUTO_EXCE_TASK = "WaveAutoExce";
}