| | |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import java.util.List; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * 焊缝Service业务层处理 |
| | |
| | | List<Long> years = apsWeldSeamStatistics.stream().map(ApsWeldSeamStatistics::getYear).distinct().toList(); |
| | | List<Long> months = apsWeldSeamStatistics.stream().map(ApsWeldSeamStatistics::getMonth).distinct().toList(); |
| | | List<String> bases = apsWeldSeamStatistics.stream().map(ApsWeldSeamStatistics::getProductionBase).distinct().toList(); |
| | | |
| | | /*工单类型:订单*/ |
| | | String WorkOrderType_Order="0"; |
| | | /*工单类型:预测*/ |
| | | String WorkOrderType_Prediction="1"; |
| | | /*类型:气体*/ |
| | | String Classification_Gas="0"; |
| | | /*类型:管路*/ |
| | | String Classification_Piping="1"; |
| | | for (Long year : years) { |
| | | for (Long month : months) { |
| | | for (String basis : bases) { |
| | | List<ApsWeldSeamStatistics> list = apsWeldSeamStatistics.stream() |
| | | .filter(x -> x.getYear().equals(year) && x.getMonth().equals(month) && x.getProductionBase().equals(basis)).toList(); |
| | | |
| | | long gasOrderRequirement = list.stream().filter(x -> x.getWorkOrderType().equals("0") && x.getClassification().equals("0")) |
| | | long gasOrderRequirement = list.stream().filter(x -> x.getWorkOrderType().equals(WorkOrderType_Order) && x.getClassification().equals(Classification_Gas)) |
| | | .mapToLong(ApsWeldSeamStatistics::getTotal).sum(); |
| | | long gasPredictionRequirement = list.stream().filter(x -> x.getWorkOrderType().equals("1") && x.getClassification().equals("0")) |
| | | long gasPredictionRequirement = list.stream().filter(x -> x.getWorkOrderType().equals(WorkOrderType_Prediction) && x.getClassification().equals(Classification_Gas)) |
| | | .mapToLong(ApsWeldSeamStatistics::getTotal).sum(); |
| | | long pipingOrderRequirement = list.stream().filter(x -> x.getWorkOrderType().equals("0") && x.getClassification().equals("1")) |
| | | long pipingOrderRequirement = list.stream().filter(x -> x.getWorkOrderType().equals(WorkOrderType_Order) && x.getClassification().equals(Classification_Piping)) |
| | | .mapToLong(ApsWeldSeamStatistics::getTotal).sum(); |
| | | long pipingPredictionRequirement = list.stream().filter(x -> x.getWorkOrderType().equals("1") && x.getClassification().equals("1")) |
| | | long pipingPredictionRequirement = list.stream().filter(x -> x.getWorkOrderType().equals(WorkOrderType_Prediction) && x.getClassification().equals(Classification_Piping)) |
| | | .mapToLong(ApsWeldSeamStatistics::getTotal).sum(); |
| | | long total = gasOrderRequirement + gasPredictionRequirement + pipingOrderRequirement + pipingPredictionRequirement; |
| | | if(total>0) { |
| | |
| | | }*/ |
| | | return 1; |
| | | } |
| | | |
| | | @Override |
| | | public List<List<String>> weldSeamEchartsList(ApsWeldSeam apsWeldSeam) { |
| | | |
| | | Map<String, Object> params = apsWeldSeam.getParams(); |
| | | if(ObjectUtils.isNotEmpty(params)){ |
| | | String startDay = params.get("startDay").toString(); |
| | | String endDay = params.get("endDay").toString(); |
| | | List<Long> produceYears = new ArrayList<>(); |
| | | List<Long> produceMonths = new ArrayList<>(); |
| | | String startQueryYear = startDay.substring(0,4); |
| | | String endQueryYear = endDay.substring(0,4); |
| | | String startQueryDay = startDay.substring(6,7); |
| | | String endQueryDay = endDay.substring(6,7); |
| | | produceYears.add(Long.valueOf(startQueryYear)); |
| | | produceYears.add(Long.valueOf(endQueryYear)); |
| | | produceMonths.add(Long.valueOf(startQueryDay)); |
| | | produceMonths.add(Long.valueOf(endQueryDay)); |
| | | apsWeldSeam.setProduceYears(produceYears); |
| | | apsWeldSeam.setProduceMonths(produceMonths); |
| | | } |
| | | List<Map> mapList =apsWeldSeamMapper.weldSeamEcharts(apsWeldSeam); |
| | | Set monthSet=mapList.stream().map(e->e.get("produce_month").toString()).collect(Collectors.toSet()); |
| | | List monthList = new ArrayList(monthSet); |
| | | Collections.sort(monthList); |
| | | |
| | | List<List<String>> echartsList = new ArrayList<>(); |
| | | |
| | | Set<String> titleSet = new HashSet<>(); |
| | | List<String> title = new ArrayList<>(titleSet); |
| | | title.add("product"); |
| | | mapList.forEach(item->{ |
| | | StringBuilder sb = new StringBuilder(); |
| | | sb.append(item.get("production_base")); |
| | | sb.append("-"); |
| | | sb.append(item.get("work_order_name")); |
| | | sb.append("-"); |
| | | sb.append(item.get("classification_name")); |
| | | title.add(sb.toString()); |
| | | |
| | | }); |
| | | echartsList.add(title); |
| | | System.out.println(monthList); |
| | | monthList.forEach(month->{ |
| | | List<String> table = new ArrayList<>(); |
| | | table.add(month+"月"); |
| | | for (int i=1;i<title.size();i++){ |
| | | for(int j=0;j<mapList.size();j++){ |
| | | Map value =mapList.get(j); |
| | | StringBuilder sb = new StringBuilder(); |
| | | sb.append(value.get("production_base")); |
| | | sb.append("-"); |
| | | sb.append(value.get("work_order_name")); |
| | | sb.append("-"); |
| | | sb.append(value.get("classification_name")); |
| | | if(sb.toString().equals(title.get(i))){//列明 |
| | | table.add(value.get("total_weld_seam").toString()); |
| | | } |
| | | } |
| | | } |
| | | echartsList.add(table); |
| | | }); |
| | | return echartsList; |
| | | } |
| | | } |