春风项目四线(合箱线、总装线)
wujian
2024-01-25 c6e06980cccbb86fa224633d3585f9164295bff1
jcdm-main/src/main/java/com/jcdm/main/bs/orderScheduling/service/impl/BsOrderSchedulingServiceImpl.java
@@ -1,14 +1,26 @@
package com.jcdm.main.bs.orderScheduling.service.impl;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.ObjectUtil;
import com.jcdm.common.utils.DateUtils;
import com.jcdm.common.utils.StringUtils;
import com.jcdm.main.bs.orderScheduling.Query.PrepareOnlineQuery;
import com.jcdm.main.bs.orderScheduling.domain.BsOrderScheduling;
import com.jcdm.main.bs.orderScheduling.mapper.BsOrderSchedulingMapper;
import com.jcdm.main.bs.orderScheduling.service.IBsOrderSchedulingService;
import com.jcdm.main.bs.orderScheduling.vo.LineChartVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.text.SimpleDateFormat;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
 * 订单排产Service业务层处理
@@ -51,6 +63,53 @@
        return bsOrderSchedulingMapper.selectBsOrderSchedulingList(bsOrderScheduling);
    }
    @Override
    public List<LineChartVO> getOffLineNum()
    {
        List<LineChartVO> result = new ArrayList<>();
        BsOrderScheduling bsOrderScheduling =  new BsOrderScheduling();
        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
        LocalDateTime now = LocalDateTime.now();
        LocalDateTime startTime = LocalDateTime.of(now.getYear(),now.getMonthValue(),now.getDayOfMonth(),8,0,0);
        LocalDateTime endTime = LocalDateTime.of(now.getYear(),now.getMonthValue(),now.plusDays(1).getDayOfMonth(),22,0,0);
        String s1 = startTime.format(formatter);
        String s2 = endTime.format(formatter);
        bsOrderScheduling.setStartTime(s1);
        bsOrderScheduling.setEndTime(s2);
        List<BsOrderScheduling> todayList = bsOrderSchedulingMapper.selectBsOrderSchedulingList(bsOrderScheduling);
        todayList = todayList.stream().filter(x -> ObjectUtil.isNotEmpty(x.getCvtOfflineTime())).collect(Collectors.toList());
        if (CollUtil.isNotEmpty(todayList)){
            List<String> allModel = todayList.stream().map(BsOrderScheduling::getModel).distinct().collect(Collectors.toList());
            Map<String, List<BsOrderScheduling>> collect = new HashMap<>();
            for (String s : allModel) {
                LineChartVO vo = new LineChartVO();
                List<Integer> arr = new ArrayList<>();
                vo.setName(s);
                collect = todayList.stream().filter(x -> s.equals(x.getModel())).collect(Collectors.groupingBy(item -> new SimpleDateFormat("yyyy-MM-dd HH").format(item
                        .getCvtOfflineTime())));
                Map<Integer,Integer> temp = new HashMap<>();
                if (CollUtil.isNotEmpty(collect)){
                    for (String string : collect.keySet()) {
                        int size = collect.get(string).size();
                        String s3 = string.split(StringUtils.SPACE)[1];
                        if (StringUtils.isNotEmpty(s3)){
                            int i = Integer.parseInt(s3);
                            temp.put(i,size);
                        }
                    }
                }
                for (int i = 8; i < 23; i++) {
                    arr.add(temp.getOrDefault(i, 0));
                }
                vo.setData(arr);
                vo.setType("line");
                result.add(vo);
            }
        }
        return result;
    }
    /**
     * 查询合箱上线列表