| | |
| | | } from 'react-admin'; |
| | | import { PAGE_DRAWER_WIDTH, OPERATE_MODE, DEFAULT_PAGE_SIZE } from '@/config/setting'; |
| | | import PauseCircleOutlineIcon from '@mui/icons-material/PauseCircleOutline'; |
| | | import StopCircleOutlinedIcon from '@mui/icons-material/StopCircleOutlined'; |
| | | import PlayArrowOutlinedIcon from '@mui/icons-material/PlayArrowOutlined'; |
| | | import { Box, Typography, Card, Stack } from '@mui/material'; |
| | | import ContentCreate from '@mui/icons-material/Create'; |
| | |
| | | <TextField source="memo" label="common.field.memo" sortable={false} /> |
| | | <TextField source="exceStatus$" label="table.field.waveItem.exceStatus" /> |
| | | <WrapperField cellClassName="opt" label="common.field.opt"> |
| | | <BulkPauseButton /> |
| | | <PauseButton /> |
| | | <ContinueButton /> |
| | | </WrapperField> |
| | | </StyledDatagrid> |
| | |
| | | ) |
| | | } |
| | | |
| | | const BulkPauseButton = () => { |
| | | const { data, selectedIds, onUnselectItems } = useListContext(); |
| | | const PauseButton = () => { |
| | | const notify = useNotify() |
| | | const refresh = useRefresh(); |
| | | const record = useRecordContext(); |
| | | const pauseClick = async () => { |
| | | const { data: { code, data, msg } } = await request.post('/waveItem/pause/pub', { wave: waveId, waveItem: selectedIds }); |
| | | const { data: { code, data, msg } } = await request.post('/waveItem/pause/pub/' + record?.id); |
| | | if (code === 200) { |
| | | notify(msg); |
| | | } else { |
| | | notify(msg); |
| | | } |
| | | refresh() |
| | | } |
| | | return ( |
| | | record?.exceStatus == 1 ? <Button label="toolbar.pause" onClick={pauseClick} startIcon={<PauseCircleOutlineIcon />} /> : <></> |
| | | record?.exceStatus == 1 ? <Button label="toolbar.pause" onClick={pauseClick} startIcon={<StopCircleOutlinedIcon />} /> : <></> |
| | | ) |
| | | } |
| | | |
| | | const ContinueButton = () => { |
| | | const { data, selectedIds, onUnselectItems } = useListContext(); |
| | | const notify = useNotify() |
| | | const refresh = useRefresh(); |
| | | const record = useRecordContext(); |
| | | const continueClick = async () => { |
| | | const { data: { code, data, msg } } = await request.post('/waveItem/continue/pub', { wave: waveId, waveItem: selectedIds }); |
| | | const { data: { code, data, msg } } = await request.post('/waveItem/continue/pub/' + record?.id); |
| | | if (code === 200) { |
| | | notify(msg); |
| | | } else { |
| | | notify(msg); |
| | | } |
| | | refresh() |
| | | } |
| | | return ( |
| | | record?.exceStatus == 4 ? <Button label="toolbar.continuePub" onClick={continueClick} startIcon={<PauseCircleOutlineIcon />} /> : <></> |
| | | record?.exceStatus == 2 ? <Button label="toolbar.continuePub" onClick={continueClick} startIcon={<PauseCircleOutlineIcon />} /> : <></> |
| | | ) |
| | | } |
| | |
| | | |
| | | @PreAuthorize("hasAuthority('manager:waveItem:update')") |
| | | @ApiOperation("暂停下发任务") |
| | | @PostMapping("/waveItem/pause/pub") |
| | | @PostMapping("/waveItem/pause/pub/{id}") |
| | | public R pausePublicTask(@PathVariable Long id) { |
| | | waveItemService.update(new LambdaUpdateWrapper<WaveItem>() |
| | | .eq(WaveItem::getId, id) |
| | |
| | | |
| | | @PreAuthorize("hasAuthority('manager:waveItem:update')") |
| | | @ApiOperation("继续下发任务") |
| | | @PostMapping("/waveItem/continue/pub") |
| | | @PostMapping("/waveItem/continue/pub/{id}") |
| | | 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)); |
| | | .set(WaveItem::getExceStatus, WaveItemExceStatus.WAVE_EXCE_STATUS_ING.val)); |
| | | return R.ok(); |
| | | } |
| | | |
| | |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.Date; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.fasterxml.jackson.annotation.JsonFormat; |
| | | import com.vincent.rsf.server.system.constant.DictTypeCode; |
| | | import com.vincent.rsf.server.system.entity.DictData; |
| | | import com.vincent.rsf.server.system.service.DictDataService; |
| | | import lombok.experimental.Accessors; |
| | | import org.springframework.format.annotation.DateTimeFormat; |
| | | import java.text.SimpleDateFormat; |
| | |
| | | import com.vincent.rsf.server.system.entity.User; |
| | | import java.io.Serializable; |
| | | import java.util.Date; |
| | | import java.util.Objects; |
| | | |
| | | @Data |
| | | @TableName("man_wave") |
| | |
| | | } |
| | | |
| | | public String getExceStatus$(){ |
| | | if (null == this.exceStatus){ return null; } |
| | | switch (this.exceStatus){ |
| | | case 0: |
| | | return "初始化"; |
| | | case 1: |
| | | return "生成任务"; |
| | | case 2: |
| | | return "任务播种"; |
| | | case 3: |
| | | return "完成"; |
| | | default: |
| | | return String.valueOf(this.exceStatus); |
| | | if (Cools.isEmpty(this.exceStatus)) { |
| | | return null; |
| | | } |
| | | DictDataService dictDataService = SpringUtils.getBean(DictDataService.class); |
| | | DictData dictDatas = dictDataService.getOne(new LambdaQueryWrapper<DictData>() |
| | | .eq(DictData::getDictTypeCode, DictTypeCode.SYS_WAVE_EXCE_STATUS) |
| | | .eq(DictData::getValue, this.exceStatus)); |
| | | if (Objects.isNull(dictDatas) || Objects.isNull(dictDatas.getLabel())) { |
| | | return null; |
| | | } |
| | | return dictDatas.getValue() + "." + dictDatas.getLabel(); |
| | | } |
| | | |
| | | public String getStatus$(){ |
| | |
| | | } |
| | | DictDataService dictDataService = SpringUtils.getBean(DictDataService.class); |
| | | DictData dictDatas = dictDataService.getOne(new LambdaQueryWrapper<DictData>() |
| | | .eq(DictData::getDictTypeCode, DictTypeCode.SYS_WAVE_EXCE_STATUS) |
| | | .eq(DictData::getDictTypeCode, DictTypeCode.SYS_WAVE_ITEM_EXCE_STATUS) |
| | | .eq(DictData::getValue, this.exceStatus)); |
| | | if (Objects.isNull(dictDatas) || Objects.isNull(dictDatas.getLabel())) { |
| | | return null; |
| | |
| | | |
| | | //波次执行状态 |
| | | WAVE_EXCE_STATUS_INIT("0", "初始化"), |
| | | WAVE_EXCE_STATUS_TASK("1", "生成任务"), |
| | | WAVE_EXCE_STATUS_SPEED("2", "播种任务"), |
| | | WAVE_EXCE_STATUS_DONE("3", "完成"), |
| | | WAVE_EXCE_STATUS_EXCING("1", "执行中"), |
| | | WAVE_EXCE_STATUS_TASK("2", "生成任务"), |
| | | WAVE_EXCE_STATUS_DONE("3", "任务完成"), |
| | | ; |
| | | |
| | | WaveExceStatus(String val, String desc) { |
| | |
| | | //波次执行状态 |
| | | 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", "下发完成"), |
| | | WAVE_ITEM_EXCE_PAUSE("2", "暂停"), |
| | | WAVE_EXCE_STATUS_PUBD("3", "已下发"), |
| | | WAVE_EXCE_STATUS_DONE("4", "任务完成"), |
| | | ; |
| | | |
| | | WaveItemExceStatus(String val, String desc) { |
| | |
| | | |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; |
| | | 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.enums.WaveItemExceStatus; |
| | | import com.vincent.rsf.server.manager.service.WaveItemService; |
| | | import com.vincent.rsf.server.manager.service.WaveService; |
| | | import com.vincent.rsf.server.manager.service.impl.TaskItemServiceImpl; |
| | | 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.stereotype.Component; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.Objects; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | |
| | | |
| | | @Autowired |
| | | private ConfigService configService; |
| | | |
| | | @Autowired |
| | | private TaskItemServiceImpl taskItemService; |
| | | |
| | | |
| | | /** |
| | |
| | | * @time 2025/6/23 13:52 |
| | | */ |
| | | @Scheduled(cron = "0/15 * * * * ?") |
| | | @Transactional(rollbackFor = Exception.class) |
| | | // @Transactional(rollbackFor = Exception.class) |
| | | 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<Wave> list = waveService.list(new LambdaQueryWrapper<Wave>() |
| | | // .select(Wave::getId) |
| | | // .in(Wave::getExceStatus, WaveExceStatus.WAVE_EXCE_STATUS_INIT.val |
| | | // , WaveExceStatus.WAVE_EXCE_STATUS_EXCING.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::getWaveId, longs) |
| | | .eq(WaveItem::getExceStatus, WaveItemExceStatus.WAVE_ITEM_EXCE_STATUS_UN.val)); |
| | | .in(WaveItem::getExceStatus, Arrays.asList(WaveItemExceStatus.WAVE_ITEM_EXCE_STATUS_UN.val |
| | | , WaveItemExceStatus.WAVE_EXCE_STATUS_ING.val))); |
| | | |
| | | waveItemService.update(new LambdaUpdateWrapper<WaveItem>() |
| | | .set(WaveItem::getExceStatus, WaveItemExceStatus.WAVE_EXCE_STATUS_ING.val) |
| | | .apply("anfme > work_qty") |
| | | ); |
| | | |
| | | if (waveItems.isEmpty()) { |
| | | return; |
| | | } |
| | |
| | | waveService.waveToTask(params, loginUserId); |
| | | }); |
| | | } |
| | | |
| | | } |
| | |
| | | throw new CoolException("波次明细不存在!!"); |
| | | } |
| | | |
| | | if (!waveItemService.update(new LambdaUpdateWrapper<WaveItem>() |
| | | .set(WaveItem::getExceStatus, WaveItemExceStatus.WAVE_EXCE_STATUS_ING.val) |
| | | .in(WaveItem::getId, waveItems))) { |
| | | throw new CoolException("执行状态修改失败!!"); |
| | | } |
| | | |
| | | WaveRule waveRule = waveRuleService.getOne(new LambdaQueryWrapper<WaveRule>() |
| | | .eq(WaveRule::getType, WaveRuleType.First_In_First_Out.type)); |
| | | if (Cools.isEmpty(waveRule)) { |
| | |
| | | params.add(locParams); |
| | | } |
| | | List<OrderOutItemDto> results = LocManageUtil.getOutOrderList(params, waveRule); |
| | | |
| | | if (results.isEmpty()) { |
| | | waveService.update(new LambdaUpdateWrapper<Wave>() |
| | | .set(Wave::getExceStatus, WaveExceStatus.WAVE_EXCE_STATUS_EXCING.val) |
| | | .set(Wave::getUpdateBy, loginUserId) |
| | | .set(Wave::getUpdateTime, new Date()) |
| | | .eq(Wave::getId, waveId)); |
| | | return R.ok(); |
| | | } |
| | | /**生成出库任务*/ |
| | | try { |
| | | generateOutTask(results, loginUserId, waves); |
| | |
| | | throw new CoolException(e.getMessage()); |
| | | } |
| | | |
| | | List<TaskItem> taskItems = taskItemService.list(new LambdaQueryWrapper<TaskItem>().in(TaskItem::getSource, waveItems)); |
| | | List<TaskItem> taskItems = taskItemService.list(new LambdaQueryWrapper<TaskItem>() |
| | | .in(TaskItem::getSource, waveItems)); |
| | | if (Cools.isEmpty(taskItems)) { |
| | | throw new CoolException("数据错误:波次明细已不存在!!"); |
| | | throw new CoolException("暂无合适库存信息!!"); |
| | | } |
| | | for (TaskItem item : taskItems) { |
| | | WaveItem waveItem = waveItemService.getById(item.getSource()); |
| | | |
| | | Double workQty = Math.round((waveItem.getWorkQty() + item.getAnfme()) * 10000) / 10000.0; |
| | | waveItem.setWorkQty(workQty); |
| | | if (workQty.compareTo(waveItem.getAnfme()) < 0) { |
| | | waveItem.setExceStatus(WaveItemExceStatus.WAVE_EXCE_STATUS_ING.val); |
| | | } else { |
| | | waveItem.setExceStatus(WaveItemExceStatus.WAVE_EXCE_STATUS_PUBD.val); |
| | | } |
| | | |
| | | if (!waveItemService.update(new LambdaUpdateWrapper<WaveItem>() |
| | | .set(WaveItem::getExceStatus, WaveItemExceStatus.WAVE_EXCE_STATUS_ING.val) |
| | | .set(WaveItem::getWorkQty, item.getAnfme()) |
| | | .in(WaveItem::getId, waveItems))) { |
| | | .set(WaveItem::getExceStatus, WaveItemExceStatus.WAVE_EXCE_STATUS_PUBD.val) |
| | | .setSql("work_qty = work_qty + " + item.getAnfme()) |
| | | .set(WaveItem::getUpdateBy, loginUserId) |
| | | .set(WaveItem::getUpdateTime, new Date()) |
| | | .eq(WaveItem::getId, item.getSource()))) { |
| | | throw new CoolException("下发执行异常,请稍候重试!"); |
| | | } |
| | | } |
| | | if (!waveService.update(new LambdaUpdateWrapper<Wave>() |
| | | .set(Wave::getExceStatus, WaveExceStatus.WAVE_EXCE_STATUS_TASK.val) |
| | | .set(Wave::getWorkQty, taskItems.stream().mapToDouble(TaskItem::getAnfme).sum()) |
| | | .set(Wave::getUpdateBy, loginUserId) |
| | | .set(Wave::getUpdateTime, new Date()) |
| | | .eq(Wave::getId, waveId))) { |
| | | throw new CoolException("波次状态修改失败!!"); |
| | | } |
| | |
| | | @Synchronized |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void generateOutTask(List<OrderOutItemDto> itemParams, Long loginUserId, Wave wave) throws Exception { |
| | | |
| | | for (OrderOutItemDto itemDto : itemParams) { |
| | | LocToTaskParams taskParams = new LocToTaskParams(); |
| | | Loc loc = locService.getById(itemDto.getLocId()); |
| | |
| | | .setTarLoc(loc.getCode()); |
| | | locItemService.generateTask(TaskResouceType.TASK_RESOUCE_WAVE_TYPE.val, taskParams, loginUserId); |
| | | } |
| | | |
| | | // /**修改波次执行数量*/ |
| | | // taskItems.forEach(item -> { |
| | | // boolean update = waveItemService.update(new LambdaUpdateWrapper<WaveItem>() |
| | | // .eq(WaveItem::getId, item.getSource()) |
| | | // .set(WaveItem::getExceStatus, WaveItemExceStatus.WAVE_EXCE_STATUS_SEED.val) |
| | | // .set(WaveItem::getWorkQty, item.getAnfme())); |
| | | // if (!update) { |
| | | // throw new CoolException("波次执行数量修改失败!!"); |
| | | // } |
| | | // }); |
| | | // |
| | | // List<WaveItem> waveItems = waveItemService.list(new LambdaQueryWrapper<WaveItem>().eq(WaveItem::getWaveId, wave.getId())); |
| | | // double sum = waveItems.stream().mapToDouble(WaveItem::getWorkQty).sum(); |
| | | // /**波次主单信息修改*/ |
| | | // if (!this.update(new LambdaUpdateWrapper<Wave>() |
| | | // .eq(Wave::getId, wave.getId()) |
| | | // .set(Wave::getWorkQty, sum) |
| | | // .set(Wave::getExceStatus, WaveExceStatus.WAVE_EXCE_STATUS_TASK.val))) { |
| | | // throw new CoolException("波次主单信息修改失败!!"); |
| | | // } |
| | | } |
| | | |
| | | /** |
| | |
| | | public final static String SYS_WAVE_RULE_CODE = "sys_wave_rule_code"; |
| | | |
| | | /** |
| | | * 波次明细下发执行状态 |
| | | */ |
| | | public final static String SYS_WAVE_ITEM_EXCE_STATUS = "sys_wave_item_exce_status"; |
| | | |
| | | |
| | | /** |
| | | * 波次下发执行状态 |
| | | */ |
| | | public final static String SYS_WAVE_EXCE_STATUS = "sys_wave_exce_status"; |
| | | |
| | | } |
| | |
| | | # global-config:
|
| | | # field-strategy: 0
|
| | | configuration:
|
| | | log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
|
| | | # log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
|
| | | map-underscore-to-camel-case: true
|
| | | cache-enabled: true
|
| | | call-setters-on-nulls: true
|