| | |
| | | import com.vincent.rsf.server.api.entity.dto.PoItemsDto; |
| | | import com.vincent.rsf.server.api.service.ReceiveMsgService; |
| | | import com.vincent.rsf.server.api.service.ReportMsgService; |
| | | import com.vincent.rsf.server.common.utils.DateUtils; |
| | | import com.vincent.rsf.server.manager.controller.dto.DashboardDto; |
| | | import com.vincent.rsf.server.manager.controller.dto.StockTrandDto; |
| | | import com.vincent.rsf.server.manager.controller.dto.StockTransItemDto; |
| | | import com.vincent.rsf.server.manager.controller.params.AsnOrderAndItemsParams; |
| | | import com.vincent.rsf.server.manager.controller.params.BatchUpdateParam; |
| | | import com.vincent.rsf.server.manager.entity.*; |
| | | import com.vincent.rsf.server.manager.enums.AsnExceStatus; |
| | | import com.vincent.rsf.server.manager.enums.POExceStatus; |
| | | import com.vincent.rsf.server.manager.enums.*; |
| | | import com.vincent.rsf.server.manager.mapper.AsnOrderMapper; |
| | | import com.vincent.rsf.server.manager.service.*; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.text.DateFormat; |
| | | import java.text.ParsePosition; |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | |
| | | private PurchaseService purchaseService; |
| | | @Autowired |
| | | private PurchaseItemService purchaseItemService; |
| | | @Autowired |
| | | private AsnOrderService asnOrderService; |
| | | @Autowired |
| | | private TaskService taskService; |
| | | |
| | | @Override |
| | | public boolean notifyInspect(List<WkOrder> orders) { |
| | |
| | | throw new CoolException("任务中单据不可删除!!"); |
| | | } |
| | | |
| | | |
| | | if (!asnOrderItemService.remove(new LambdaQueryWrapper<WkOrderItem>() |
| | | .in(WkOrderItem::getOrderId, ids))) { |
| | | // throw new CoolException("Details Delete Fail"); |
| | |
| | | } |
| | | |
| | | /** |
| | | * 获取首页表头数据 |
| | | * @return |
| | | */ |
| | | @Override |
| | | public R getDashbord() { |
| | | DashboardDto dto = new DashboardDto(); |
| | | //获取入库数量 |
| | | DashboardDto trandDto = this.baseMapper.getDashbord(OrderType.ORDER_IN.type, TaskType.TASK_TYPE_IN.type + ""); |
| | | dto.setInAnf(trandDto.getAnfme()).setTaskIn(trandDto.getRealAnfme()).setTotalIn(trandDto.getAnfme() + trandDto.getRealAnfme()); |
| | | |
| | | //获取出库单数量 |
| | | DashboardDto outTrand = this.baseMapper.getDashbord(OrderType.ORDER_OUT.type, TaskType.TASK_TYPE_OUT.type + ""); |
| | | dto.setOutAnf(outTrand.getAnfme()).setTaskOut(outTrand.getRealAnfme()).setTotalOut(outTrand.getAnfme() + outTrand.getRealAnfme()); |
| | | |
| | | //获取执行中任务数量 |
| | | List<Task> tasks = taskService.list(new LambdaQueryWrapper<>()); |
| | | if (!tasks.isEmpty()) { |
| | | outTrand.setTaskQty(tasks.size()); |
| | | } |
| | | return R.ok().add(dto); |
| | | } |
| | | |
| | | /** |
| | | * 获取出入库趋势 |
| | | * @return |
| | | */ |
| | | @Override |
| | | public R getStockTrand() { |
| | | List<String> days = DateUtils.getLastMonthDays("yyyy-MM-dd"); |
| | | LambdaQueryWrapper<StockStatistic> queryWrapper = new LambdaQueryWrapper<StockStatistic>() |
| | | .in(StockStatistic::getTaskType, Arrays.asList(TaskType.TASK_TYPE_IN.type, TaskType.TASK_TYPE_OUT.type)); |
| | | List<StockTransItemDto> items = this.baseMapper.getStockTrand(queryWrapper); |
| | | if (items.isEmpty()) { |
| | | return R.ok(); |
| | | } |
| | | List<StockTransItemDto> stockDtos = new ArrayList<>(); |
| | | days.forEach(day -> { |
| | | StockTransItemDto itemDto = new StockTransItemDto(); |
| | | itemDto.setInQty(0).setOutQty(0).setOutAnfme(0).setOutAnfme(0); |
| | | items.forEach(item -> { |
| | | if (item.getOrderTime().equals(day)) { |
| | | BeanUtils.copyProperties(item, itemDto); |
| | | } |
| | | }); |
| | | itemDto.setOrderTime(day); |
| | | stockDtos.add(itemDto); |
| | | }); |
| | | |
| | | //获取最大值 |
| | | Optional<Integer> max = stockDtos.stream().map(StockTransItemDto::getInQty).filter(Objects::nonNull).max(Comparator.naturalOrder()); |
| | | Optional<Integer> maxOut = stockDtos.stream().map(StockTransItemDto::getOutQty).filter(Objects::nonNull).max(Comparator.naturalOrder()); |
| | | int maxed = Math.max(max.orElse(Integer.MIN_VALUE), maxOut.orElse(Integer.MIN_VALUE)); |
| | | |
| | | StockTrandDto trandDto = new StockTrandDto(); |
| | | trandDto.setMaxQty(maxed).setTrandItem(stockDtos); |
| | | return R.ok().add(trandDto); |
| | | } |
| | | |
| | | /** |
| | | * @param |
| | | * @return |
| | | * @author Ryan |