|  |  | 
 |  |  | package com.doumee.service.business.impl.thrid; | 
 |  |  |  | 
 |  |  | import com.alibaba.fastjson.JSONObject; | 
 |  |  | import com.alibaba.fastjson.TypeReference; | 
 |  |  | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; | 
 |  |  | import com.doumee.biz.system.SystemDictDataBiz; | 
 |  |  | import com.doumee.core.constants.ResponseStatus; | 
 |  |  | 
 |  |  | import com.doumee.core.haikang.model.param.respose.*; | 
 |  |  | import com.doumee.core.haikang.service.HKCarOpenService; | 
 |  |  | import com.doumee.core.haikang.service.HKService; | 
 |  |  | import com.doumee.core.tms.model.TMSContants; | 
 |  |  | import com.doumee.core.tms.model.request.TmsFacrotyCodeListRequest; | 
 |  |  | import com.doumee.core.tms.model.request.TmsOrderNoFinishListRequest; | 
 |  |  | import com.doumee.core.tms.model.request.TmsOutQtyAndVehicleQtyRequest; | 
 |  |  | import com.doumee.core.tms.model.response.TmsDistributionOfDeliveryLocResponse; | 
 |  |  | import com.doumee.core.tms.model.response.TmsInventoryListResponse; | 
 |  |  | import com.doumee.core.tms.model.response.TmsOutQtyAndVehicleQtyResponse; | 
 |  |  | import com.doumee.core.tms.model.response.TmsTotalAndReportVehicleQtyResponse; | 
 |  |  | import com.doumee.core.tms.model.request.TmsSevenArrivalDetailsRequest; | 
 |  |  | import com.doumee.core.tms.model.response.*; | 
 |  |  | import com.doumee.core.utils.Constants; | 
 |  |  | import com.doumee.core.utils.DateUtil; | 
 |  |  | import com.doumee.core.utils.Utils; | 
 |  |  | 
 |  |  | import org.apache.commons.lang3.StringUtils; | 
 |  |  | import org.springframework.beans.BeanUtils; | 
 |  |  | import org.springframework.beans.factory.annotation.Autowired; | 
 |  |  | import org.springframework.beans.factory.annotation.Value; | 
 |  |  | import org.springframework.stereotype.Service; | 
 |  |  |  | 
 |  |  | import java.math.BigDecimal; | 
 |  |  | 
 |  |  |     private PlatformGroupMapper platformGroupMapper; | 
 |  |  |     @Autowired | 
 |  |  |     private TmsService tmsService; | 
 |  |  |  | 
 |  |  |     @Value("${debug_model}") | 
 |  |  |     private Boolean isDebug; | 
 |  |  |     /** | 
 |  |  |      * 获取区域树形结构数据 | 
 |  |  |      * @return | 
 |  |  | 
 |  |  |                         .apply("to_days(done_date) = to_days(now())") ); | 
 |  |  |                 if(jobs!=null){ | 
 |  |  |                     for(PlatformJob j :jobs){ | 
 |  |  |                         num =num.add(Constants.formatBigdecimal(j.getTotalNum())); | 
 |  |  |                         if(Objects.nonNull(j)&&Objects.nonNull(j.getTotalNum())){ | 
 |  |  |                             num =num.add(Constants.formatBigdecimal(j.getTotalNum())); | 
 |  |  |                         } | 
 |  |  |  | 
 |  |  |                     } | 
 |  |  |                 } | 
 |  |  |             }else{ | 
 |  |  | 
 |  |  |                                 , Constants.PlatformJobStatus.LEAVED.getKey()) ); | 
 |  |  |                 if(jobs!=null){ | 
 |  |  |                     for(PlatformJob j :jobs){ | 
 |  |  |                         num = num.add(Constants.formatBigdecimal(j.getTotalNum())); | 
 |  |  |                         if(Objects.nonNull(j)&&Objects.nonNull(j.getTotalNum())){ | 
 |  |  |                             num = num.add(Constants.formatBigdecimal(j.getTotalNum())); | 
 |  |  |                         } | 
 |  |  |                     } | 
 |  |  |                 } | 
 |  |  |             } | 
 |  |  | 
 |  |  |         BaseResponse<CamerasPreviewURLsResponse> result = HKService.cameraPreviewURLs(request); | 
 |  |  |         if(result!=null && StringUtils.equals(result.getCode(),HKConstants.RESPONSE_SUCCEE) && result.getData()!=null){ | 
 |  |  |             return result.getData().getUrl(); | 
 |  |  |  | 
 |  |  |         } | 
 |  |  |         return null; | 
 |  |  |     } | 
 |  |  | 
 |  |  |                         .selectAs(PlatformJob::getId,PlatformJob::getId) | 
 |  |  |                         .selectAs(PlatformJob::getCreateDate,PlatformJob::getCreateDate) | 
 |  |  |                         .selectAs(PlatformJob::getTotalNum,PlatformJob::getTotalNum) | 
 |  |  |                         .selectAs(PlatformJob::getStatus,PlatformJob::getStatus) | 
 |  |  | //                        .select("select sum(io_qty) from platform_wms_details a where a.isdeleted=0 and a.job_id=t.id",create_date) | 
 |  |  |                         .eq(PlatformJob::getIsdeleted,Constants.ZERO) | 
 |  |  |                         .apply(queryType==0,"to_days(create_date) >= to_days(now()) -7") | 
 |  |  | 
 |  |  |                     .isNotNull(PlatformLog::getParam3) | 
 |  |  |                     .ne(PlatformLog::getParam3,Constants.ZERO+"")); | 
 |  |  |             if(platformLogList!=null && platformLogList.size()>0){ | 
 |  |  |                 return new BigDecimal((double)(platformLogList.stream().map(m->Long.valueOf(m.getParam3())).reduce(Long.valueOf(0),Long::sum))/(double)60); | 
 |  |  |                 return new BigDecimal((double)(platformLogList.stream().map(m->Long.valueOf(m.getParam3())).reduce(Long.valueOf(0),Long::sum))/(double)3600); | 
 |  |  |             } | 
 |  |  |         } | 
 |  |  |         return r; | 
 |  |  | 
 |  |  |                    //如果是在线或者休眠,查询在途还是空闲ty | 
 |  |  |                     codes.add(model.getPlateNum()); | 
 |  |  |                     model.setJobStatus(Constants.ZERO); | 
 |  |  |                 }else | 
 |  |  |                 }else{ | 
 |  |  |                     model.setJobStatus(Constants.TWO); | 
 |  |  |                     data.setOfflineNum(data.getOfflineNum()+1); | 
 |  |  |                 } | 
 |  |  |             } | 
 |  |  |             if(codes.size()>0){ | 
 |  |  |                 //状态 0待确认 1待签到 2等待叫号 3入园等待 4已叫号 5作业中 6作业完成 7转移中 8异常挂起 9已授权离园 10已离园 11 已过号  12取消(WMS) | 
 |  |  |                 List<PlatformJob> busyNum = platformJobMapper.selectList(new QueryWrapper<PlatformJob>() .lambda() | 
 |  |  | 
 |  |  |      */ | 
 |  |  |     @Override | 
 |  |  |     public  EnergyBoardVO centerEnergyData(){ | 
 |  |  |         EnergyBoardVO data = new EnergyBoardVO(); | 
 |  |  |         Random random = new Random(); | 
 |  |  |        EnergyBoardVO data = new EnergyBoardVO(); | 
 |  |  |        Random random = new Random(); | 
 |  |  |        PlatformWaterGas smoke=  platformWaterGasMapper.selectOne(new QueryWrapper<PlatformWaterGas>() | 
 |  |  |                  .select("sum(num) as num") | 
 |  |  |                 .lambda() | 
 |  |  | 
 |  |  |         } | 
 |  |  |         if( data.getGasQuantity().getTotalNum().compareTo(new BigDecimal(0)) !=0){ | 
 |  |  |             //计算用气同比环比 | 
 |  |  |             data.getGasQuantity().setSameRate(Constants.formatBigdecimal4Float(data.getGasQuantity().getSameNum().divide(data.getGasQuantity().getTotalNum(),4,BigDecimal.ROUND_HALF_UP)).doubleValue()*100 +""); | 
 |  |  |             data.getGasQuantity().setRingRate(Constants.formatBigdecimal4Float(data.getGasQuantity().getRingNum().divide(data.getGasQuantity().getTotalNum(),4,BigDecimal.ROUND_HALF_UP)).doubleValue()*100 +""); | 
 |  |  |             data.getGasQuantity().setSameRate( | 
 |  |  |                     (data.getGasQuantity().getTotalNum().subtract(data.getGasQuantity().getSameNum())).divide(data.getGasQuantity().getSameNum()).doubleValue()*100 +"" | 
 |  |  |                     /*Constants.formatBigdecimal4Float(data.getGasQuantity().getSameNum() | 
 |  |  |                             .divide(data.getGasQuantity().getTotalNum(),4,BigDecimal.ROUND_HALF_UP)).doubleValue()*100 +""*/); | 
 |  |  |             data.getGasQuantity().setRingRate( | 
 |  |  |                     (data.getGasQuantity().getTotalNum().subtract(data.getGasQuantity().getRingNum())).divide(data.getGasQuantity().getRingNum()).doubleValue()*100 +"" | 
 |  |  |                     //Constants.formatBigdecimal4Float(data.getGasQuantity().getRingNum().divide(data.getGasQuantity().getTotalNum(),4,BigDecimal.ROUND_HALF_UP)).doubleValue()*100 +"" | 
 |  |  |             ); | 
 |  |  |         } | 
 |  |  |         if( data.getWaterQuantity().getTotalNum().compareTo(new BigDecimal(0)) !=0){ | 
 |  |  |             // //计算用水同比环比 | 
 |  |  | 
 |  |  |      * @param data | 
 |  |  |      */ | 
 |  |  |     private void getLastMonthElectricityData(EnergyModelDataVO data) { | 
 |  |  |          BaseResponse<LastMonthFeeByMeterTypeResponse> response = HKService.lastMonthFeeByMeterType("1"); | 
 |  |  | //         BaseResponse<LastMonthFeeByMeterTypeResponse> response = HKService.lastMonthFeeByMeterType("1"); | 
 |  |  | //        if(response != null && StringUtils.equals(response.getCode(), HKConstants.RESPONSE_SUCCEE) && response.getData()!=null ){ | 
 |  |  | //           data.setRingRate(StringUtils.defaultString(response.getData().getRingPercent(),"0")); | 
 |  |  | //           data.setSameRate(StringUtils.defaultString(response.getData().getSamePercent(),"0")); | 
 |  |  | 
 |  |  |      * @param data | 
 |  |  |      */ | 
 |  |  |     private void getCurrentDateElectircityData(EnergyModelDataVO data,int days) { | 
 |  |  |         EnergyTrendRequest param = new EnergyTrendRequest(); | 
 |  |  |         param.setDate(DateUtil.getFomartDate(DateUtil.addDaysToDate(new Date(),days),"yyyy-MM-dd"));//日期 | 
 |  |  |         param.setMeterType(1); | 
 |  |  |         param.setShowType("4"); | 
 |  |  |         param.setNodeType(2); | 
 |  |  |         param.setNodeId("root000000"); | 
 |  |  | //        EnergyTrendRequest param = new EnergyTrendRequest(); | 
 |  |  | //        param.setDate(DateUtil.getFomartDate(DateUtil.addDaysToDate(new Date(),days),"yyyy-MM-dd"));//日期 | 
 |  |  | //        param.setMeterType(1); | 
 |  |  | //        param.setShowType("4"); | 
 |  |  | //        param.setNodeType(2); | 
 |  |  | //        param.setNodeId("root000000"); | 
 |  |  | //        param.setPeriodType("day"); | 
 |  |  | //        BigDecimal total = new BigDecimal(0); | 
 |  |  | //        BaseResponse<EnergyTrendResponse> response = HKService.energyTrend(param); | 
 |  |  | //        if(response != null && StringUtils.equals(response.getCode(), HKConstants.RESPONSE_SUCCEE) | 
 |  |  | //                && response.getData()!=null&& response.getData().getYvalues()!=null ){ | 
 |  |  | //            for (int i = 0; i < response.getData().getYvalues().get(0).getValue().length; i++) { | 
 |  |  | //                total = total.add(new BigDecimal(StringUtils.defaultString( response.getData().getYvalues().get(0).getValue()[i],"0"))); | 
 |  |  | //            } | 
 |  |  | // | 
 |  |  | //        } | 
 |  |  | //        data.setTotal(Constants.formatBigdecimal2Float(total).toString()); | 
 |  |  |         EnergyTotalDataRequest param = new EnergyTotalDataRequest(); | 
 |  |  |         param.setPeriodType("day"); | 
 |  |  |         BigDecimal total = new BigDecimal(0); | 
 |  |  |         BaseResponse<EnergyTrendResponse> response = HKService.energyTrend(param); | 
 |  |  |         if(response != null && StringUtils.equals(response.getCode(), HKConstants.RESPONSE_SUCCEE) | 
 |  |  |                 && response.getData()!=null&& response.getData().getYvalues()!=null ){ | 
 |  |  |             for (int i = 0; i < response.getData().getYvalues().get(0).getValue().length; i++) { | 
 |  |  |                 total = total.add(new BigDecimal(StringUtils.defaultString( response.getData().getYvalues().get(0).getValue()[i],"0"))); | 
 |  |  |             } | 
 |  |  |  | 
 |  |  |         param.setDate(DateUtil.getFomartDate(DateUtil.addDaysToDate(new Date(),days),"yyyy-MM-dd")); | 
 |  |  |         BaseResponse<EnergyTotalDataResponse> beforMonthResponse = HKService.energyTotal(param); | 
 |  |  |         if(beforMonthResponse != null && StringUtils.equals(beforMonthResponse.getCode(), HKConstants.RESPONSE_SUCCEE) && beforMonthResponse.getData()!=null ){ | 
 |  |  |             data.setTotal(beforMonthResponse.getData().getElectricity()); | 
 |  |  |             data.setTotalNum(new BigDecimal(beforMonthResponse.getData().getElectricity())); | 
 |  |  |         } | 
 |  |  |         data.setTotal(Constants.formatBigdecimal2Float(total).toString()); | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     private EnergyModelDataVO getDefaultData() { | 
 |  |  | 
 |  |  |                     .last(" group by DATE_FORMAT(TIME_INFO,'%Y-%m')") | 
 |  |  |             ); | 
 |  |  |             for (int i = 0; i < 12; i++) { | 
 |  |  |                 Date tempDate = DateUtil.increaseMonth(lastMonth,i); | 
 |  |  |                 Date tempDate = DateUtil.increaseMonth(lastMonth,i);     | 
 |  |  |                 EnergyDataVO data = new EnergyDataVO(); | 
 |  |  |                 data.setTimeData(DateUtil.getFomartDate(tempDate,"YYYY-MM")); | 
 |  |  |                 data.setEnergy(new BigDecimal(0)); | 
 |  |  | 
 |  |  |             for (int i = 0; i < 12; i++) { | 
 |  |  |                 Date tempDate = DateUtil.increaseMonth(lastMonth,i); | 
 |  |  |                 EnergyDataVO data = new EnergyDataVO(); | 
 |  |  |                 data.setTimeData(DateUtil.getFomartDate(tempDate,(i+1)+"月")); | 
 |  |  |                 data.setTimeData(DateUtil.getFomartDate(tempDate,"YYYY-MM")); | 
 |  |  | //                data.setTimeData(DateUtil.getFomartDate(tempDate,(i+1)+"月")); | 
 |  |  |                 data.setEnergy(new BigDecimal(0)); | 
 |  |  |                 energyDataVOList.add(data); | 
 |  |  |             } | 
 |  |  | 
 |  |  |                 (int) retentionList.stream().filter(i->Constants.equalsInteger(i.getType(),Constants.ONE)&&Objects.isNull(i.getCompanyType())).count() | 
 |  |  |         ); | 
 |  |  |         //在园车辆 | 
 |  |  |         data.setInternalCarTotal( | 
 |  |  |         data.setInParkCarTotal( | 
 |  |  |                 (int) retentionList.stream().filter(i->Constants.equalsInteger(i.getType(),Constants.THREE)).count() | 
 |  |  |         ); | 
 |  |  |         //在园相关方车辆 | 
 |  |  | 
 |  |  |                 curtotalNum += Constants.formatIntegerNum(workEfficiencyVO.getWorkNum()) ; | 
 |  |  |             } | 
 |  |  |             workEfficiencyVO.setTotalWorkNum(curtotalNum);//累计值 | 
 |  |  |             if(System.currentTimeMillis() < curTime){ | 
 |  |  |                 workEfficiencyVO.setTotalWorkNum(0); | 
 |  |  |             } | 
 |  |  |             workEfficiencyVOList.add(workEfficiencyVO); | 
 |  |  |         } | 
 |  |  |         return workEfficiencyVOList; | 
 |  |  | 
 |  |  |                     data.setReservationCar(data.getReservationCar()+Constants.formatIntegerNum(model.getCountum())); | 
 |  |  |                     data.setCalledNum(data.getCalledNum()+Constants.formatIntegerNum(model.getCountum())); | 
 |  |  |                     data.setWorkedNum(data.getWorkedNum()+Constants.formatIntegerNum(model.getCountum())); | 
 |  |  |                      data.setWorkingCar(data.getWorkingCar()+Constants.formatIntegerNum(model.getCountum())); | 
 |  |  |                 } | 
 |  |  |                 // 作业完成(预约车、签到数、已叫号、作业车、已完成) | 
 |  |  |                 if(Constants.equalsInteger(model.getStatus(),Constants.PlatformJobStatus.DONE.getKey())){ | 
 |  |  | 
 |  |  |                 } | 
 |  |  |                 // 已离园 | 
 |  |  |                 if(Constants.equalsInteger(model.getStatus(),Constants.PlatformJobStatus.LEAVED.getKey())){ | 
 |  |  |                     data.setWorkingCar(data.getWorkingCar()+Constants.formatIntegerNum(model.getCountum())); | 
 |  |  |                     // data.setWorkingCar(data.getWorkingCar()+Constants.formatIntegerNum(model.getCountum())); | 
 |  |  |                 } | 
 |  |  |                 // 已过号(预约车、签到数、排队车) | 
 |  |  |                 if(Constants.equalsInteger(model.getStatus(),Constants.PlatformJobStatus.OVER_NUMBER.getKey())){ | 
 |  |  | 
 |  |  |         } | 
 |  |  |         BaseResponse<List<RegionDataRankingDataResponse>> response = HKService.regionDataRanking(request); | 
 |  |  |         if(response != null && StringUtils.equals(response.getCode(), HKConstants.RESPONSE_SUCCEE) && response.getData()!=null ){ | 
 |  |  |             return response.getData(); | 
 |  |  |             List<RegionDataRankingDataResponse> regionDataRankingDataResponseList = new ArrayList<>(); | 
 |  |  |             for (RegionDataRankingDataResponse regionDataRankingDataResponse:response.getData()) { | 
 |  |  |                 if(StringUtils.isNotBlank(regionDataRankingDataResponse.getPercent())){ | 
 |  |  |                     if(Constants.equalsInteger(Integer.valueOf(new BigDecimal(regionDataRankingDataResponse.getPercent()).intValue()),Constants.ONE)){ | 
 |  |  |                         continue; | 
 |  |  |                     } | 
 |  |  |                     regionDataRankingDataResponseList.add(regionDataRankingDataResponse); | 
 |  |  |                 } | 
 |  |  |             } | 
 |  |  |             return regionDataRankingDataResponseList; | 
 |  |  |         }else{ | 
 |  |  |             return null; | 
 |  |  |         } | 
 |  |  |     } | 
 |  |  |     /** | 
 |  |  |      * 出库能力李永利 | 
 |  |  |      * 出库能力 | 
 |  |  |      * @return | 
 |  |  |      */ | 
 |  |  |     @Override | 
 |  |  | 
 |  |  |         if(paramList!=null){ | 
 |  |  |             String startDate = DateUtil.formatDate(new Date(),"yyyy-MM-dd"); | 
 |  |  |             String endDate = DateUtil.formatDate(new Date(),"yyyy-MM-dd"); | 
 |  |  |             if(isDebug){ | 
 |  |  |                   startDate =  "2024-12-01"; | 
 |  |  |                   endDate =   "2024-12-05"; | 
 |  |  |             } | 
 |  |  |             for(TmsFactoryParam p : paramList){ | 
 |  |  |                 WholeProvinceZxtDetailVO t = new WholeProvinceZxtDetailVO(); | 
 |  |  |                 t.setFactoryName(p.getName()); | 
 |  |  |                 t.setCurrentNum(new BigDecimal(0)); | 
 |  |  |                 t.setUseRate(new BigDecimal(0)); | 
 |  |  |                 t.setTotalNum(Constants.formatBigdecimal(p.getNum2()));//总出库能力 | 
 |  |  |                 if(StringUtils.isBlank(p.getCode())){ | 
 |  |  |                 t.setTotalNum(Constants.formatBigdecimal(p.getParam3()));//8小时出库能力 | 
 |  |  |                 if(StringUtils.isNotBlank(p.getCode())){ | 
 |  |  |                     param.setFacrotyCodeList(new ArrayList<>()); | 
 |  |  |                     param.setDateStart(startDate); | 
 |  |  |                     param.setDateEnd(endDate); | 
 |  |  | 
 |  |  |         return result; | 
 |  |  |     } | 
 |  |  |     /** | 
 |  |  |      * 全身出库能力 | 
 |  |  |      * @return | 
 |  |  |      */ | 
 |  |  |     @Override | 
 |  |  |     public  WholeProvinceBoardVO centerProvinceData(String  factoryCode){ | 
 |  |  |         WholeProvinceBoardVO data = new WholeProvinceBoardVO(); | 
 |  |  |         data.setMaxAbility(new BigDecimal(0)); | 
 |  |  |         data.setHoursAbility(new BigDecimal(0)); | 
 |  |  |         data.setCurrentPlanNum(new BigDecimal(0)); | 
 |  |  |         data.setCurrentOrderNum(new BigDecimal(0)); | 
 |  |  |         data.setCrrentRestNum(new BigDecimal(0)); | 
 |  |  |         data.setCrrentOutNum(new BigDecimal(0)); | 
 |  |  |         List<TmsFactoryParam> paramList = factoryList(); | 
 |  |  |         String code = null; | 
 |  |  |         if(paramList!=null){ | 
 |  |  |             //处理最大出库能力和8小时出库能力 | 
 |  |  |             for(TmsFactoryParam param : paramList){ | 
 |  |  |                 if(StringUtils.isNotBlank(factoryCode)){ | 
 |  |  |                     if(StringUtils.equals(param.getCode(),factoryCode)){ | 
 |  |  |                         data.setHoursAbility(Constants.formatBigdecimal(param.getParam3())); | 
 |  |  |                         data.setMaxAbility(Constants.formatBigdecimal(param.getNum2())); | 
 |  |  |                         code = param.getCode(); | 
 |  |  |                         break; | 
 |  |  |                     } | 
 |  |  |                 }else{ | 
 |  |  |                     data.setHoursAbility(data.getHoursAbility().add(Constants.formatBigdecimal(param.getParam3()))); | 
 |  |  |                     data.setMaxAbility(data.getMaxAbility().add(Constants.formatBigdecimal(param.getNum2()))); | 
 |  |  |                 } | 
 |  |  |             } | 
 |  |  |         } | 
 |  |  |       /*  Date date = new Date(); | 
 |  |  |         TmsOutQtyAndVehicleQtyRequest param = new TmsOutQtyAndVehicleQtyRequest(); | 
 |  |  |         param.setDateEnd(DateUtil.getShortTime(date)); | 
 |  |  |         param.setDateStart(DateUtil.getShortTime(date)); | 
 |  |  |         if(StringUtils.isNotBlank(code)){ | 
 |  |  |             param.setFacrotyCodeList(new ArrayList<>()); | 
 |  |  |             param.getFacrotyCodeList().add(code);//查询指定厂区 | 
 |  |  |         } | 
 |  |  |         List<TmsOutQtyAndVehicleQtyResponse> listSame=  tmsService.getOutQtyAndVehicleQty(param); | 
 |  |  |         if(listSame!=null ){ | 
 |  |  |             for(TmsOutQtyAndVehicleQtyResponse model : listSame){ | 
 |  |  |                 data.setCrrentOutNum(data.getCrrentOutNum().add(Constants.formatBigdecimal(model.getTotalOutQty())));//今日出库量 | 
 |  |  |                 data.setCrrentOutCarNum(data.getCrrentOutCarNum()+(Constants.formatIntegerNum(model.getVehicleQty())));//今日出库车次 | 
 |  |  |             } | 
 |  |  |         }*/ | 
 |  |  |         initOutboundCapability(data,factoryCode); | 
 |  |  |         return  data; | 
 |  |  |  | 
 |  |  |     } | 
 |  |  |     private void initOutboundCapability(WholeProvinceBoardVO data, String code) { | 
 |  |  |         TmsFacrotyCodeListRequest param = new TmsFacrotyCodeListRequest(); | 
 |  |  |         if(StringUtils.isNotBlank(code)){ | 
 |  |  |             param.setFacrotyCodeList(new ArrayList<>()); | 
 |  |  |             param.getFacrotyCodeList().add(code); | 
 |  |  |         } | 
 |  |  |         TmsOutboundCapabilityResponse result=  tmsService.getOutboundCapability(param); | 
 |  |  |         if(result !=null){ | 
 |  |  |             List<String> planCodes = new ArrayList<>(); | 
 |  |  |             List<String> todayCodes = new ArrayList<>(); | 
 |  |  |             String todayDate = DateUtil.getShortTime(new Date()); | 
 |  |  |             if(result.getCurrentDayOrderList()!=null && result.getCurrentDayOrderList().size()>0){ | 
 |  |  |                 for(TmsOutboundCapabilityInfoResponse model :result.getCurrentDayOrderList()){ | 
 |  |  |                     data.setCurrentOrderNum(data.getCurrentOrderNum().add(Constants.formatBigdecimal(model.getNcTotality())));//今日订单量 | 
 |  |  |                     /** | 
 |  |  |                      * DISPATCH_TYPE in(1,2) 且 TRANSPORT_CODE不为空,sum(NC_TOTALITY)  +      DISPATCH_TYPE not in(1,2) sum(NC_TOTALITY) | 
 |  |  |                      *    今日出库下达的计划任务总量 | 
 |  |  |                      */ | 
 |  |  |                     if(StringUtils.isNotBlank(model.getTransportCode()) | 
 |  |  |                             && (StringUtils.equals("1",model.getDispatchType()) || StringUtils.equals("2",model.getDispatchType()))){ | 
 |  |  |                         data.setCurrentPlanNum(data.getCurrentPlanNum().add(Constants.formatBigdecimal(model.getNcTotality())));//今日订单量 | 
 |  |  |                     } | 
 |  |  |                     if(!(StringUtils.equals("1",model.getDispatchType()) || StringUtils.equals("2",model.getDispatchType()))){ | 
 |  |  |                         data.setCurrentPlanNum(data.getCurrentPlanNum().add(Constants.formatBigdecimal(model.getNcTotality())));//今日计划量 | 
 |  |  |                     } | 
 |  |  |  | 
 |  |  |                     /** | 
 |  |  |                      * 今日下达出库的计划任务对应的运输车次数 | 
 |  |  |                      * TRANSPORT_CODE不为空count(transport_code ) | 
 |  |  |                      */ | 
 |  |  |                     if(StringUtils.isNotBlank(model.getTransportCode()) && notInList(model.getTransportCode(),planCodes)){ | 
 |  |  |                         planCodes.add(model.getTransportCode()); | 
 |  |  |                     } | 
 |  |  |                     /** | 
 |  |  |                      * 今日下达出库的计划任务对应的运输车次数 | 
 |  |  |                      * TRANSPORT_CODE不为空count(transport_code ) | 
 |  |  |                      */ | 
 |  |  |                     if(StringUtils.isNotBlank(model.getTransportCode()) && notInList(model.getTransportCode(),planCodes)){ | 
 |  |  |                         planCodes.add(model.getTransportCode()); | 
 |  |  |                     } | 
 |  |  |                     /** | 
 |  |  |                      *  out_date为当日,sum(NC_TOTALITY) 今日完成的出库作业任务总量 | 
 |  |  |                      * TRANSPORT_CODE不为空 且out_date为当日 count(transport_code)     今日完成的出库作业任务的运输车次数 | 
 |  |  |                      */ | 
 |  |  |                     if(StringUtils.isNotBlank(model.getOutDate()) && model.getOutDate().length()> 10){ | 
 |  |  |                         String tDate = model.getOutDate().substring(0,10); | 
 |  |  |                         if(tDate.equals(todayDate)){ | 
 |  |  |                             //如果是当日 | 
 |  |  |                             data.setCrrentOutNum(data.getCrrentOutNum().add(Constants.formatBigdecimal(model.getNcTotality())));//今日订单量 | 
 |  |  |                         } | 
 |  |  |                         if(StringUtils.isNotBlank(model.getTransportCode()) && notInList(model.getTransportCode(),todayCodes)){ | 
 |  |  |                             todayCodes.add(model.getTransportCode()); | 
 |  |  |                         } | 
 |  |  |                     } | 
 |  |  |                 } | 
 |  |  |             } | 
 |  |  |             if(result.getCurrentDayAgoOrderList()!=null && result.getCurrentDayAgoOrderList().size()>0){ | 
 |  |  |                 for(TmsOutboundCapabilityInfoResponse model :result.getCurrentDayAgoOrderList()){ | 
 |  |  |                     /** | 
 |  |  |                      * out_date为空,sum(NC_TOTALITY)   昨天未完成出库计划任务 | 
 |  |  |                      * out_date为空 且TRANSPORT_CODE不为空 * count(transport_code )   昨天未完成出库计划任务车次 | 
 |  |  |                      */ | 
 |  |  |                     if(StringUtils.isBlank(model.getOutDate())){ | 
 |  |  |                         data.setCurrentPlanNum(data.getCurrentPlanNum().add(Constants.formatBigdecimal(model.getNcTotality())));//今日计划量 | 
 |  |  |                         if(StringUtils.isNotBlank(model.getTransportCode()) && notInList(model.getTransportCode(),planCodes)){ | 
 |  |  |                             planCodes.add(model.getTransportCode()); | 
 |  |  |                         } | 
 |  |  |                     } | 
 |  |  |                 } | 
 |  |  |             } | 
 |  |  |             data.setCurrentPlanCarNum(planCodes.size());//今日计划车次 | 
 |  |  |             data.setCrrentOutCarNum(todayCodes.size());//今日出库车次 | 
 |  |  |         } | 
 |  |  |         data.setCrrentRestNum(data.getCurrentPlanNum().subtract(data.getCrrentOutNum())); | 
 |  |  |         data.setCrrentRestCarNum(data.getCurrentPlanCarNum() -data.getCrrentOutCarNum()); | 
 |  |  |         if(data.getCrrentRestNum().compareTo(new BigDecimal(0)) <=0){ | 
 |  |  |             data.setCrrentRestNum(new BigDecimal(0)); | 
 |  |  |         } | 
 |  |  |         if(data.getCrrentRestCarNum()<=0){ | 
 |  |  |             data.setCrrentRestCarNum(0); | 
 |  |  |         } | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     private boolean notInList(String transportCode, List<String> planCodes) { | 
 |  |  |         for(String s :planCodes){ | 
 |  |  |             if(StringUtils.equals(transportCode,s)){ | 
 |  |  |                 return  false; | 
 |  |  |             } | 
 |  |  |         } | 
 |  |  |         return true; | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     /** | 
 |  |  |      * 出库能力李永利 | 
 |  |  |      * @return | 
 |  |  |      */ | 
 |  |  |     @Override | 
 |  |  |     public    TotalOutQtyNumVO totalOutQtyNum(){ | 
 |  |  |     public    TotalOutQtyNumVO totalOutQtyNum(int type,String code){ | 
 |  |  |         TotalOutQtyNumVO  data = new TotalOutQtyNumVO(); | 
 |  |  |         data.setCurrentInYearNum(new BigDecimal(0)); | 
 |  |  |         data.setCurrentInWeekNum(new BigDecimal(0)); | 
 |  |  |         data.setCurrentInMonthNum(new BigDecimal(0)); | 
 |  |  |         data.setLastInYearNum(new BigDecimal(0)); | 
 |  |  |         data.setLastInMonthNum(new BigDecimal(0)); | 
 |  |  |         data.setLastInWeekNum(new BigDecimal(0)); | 
 |  |  |         data.setSameInMonthNum(new BigDecimal(0)); | 
 |  |  |         data.setCurrentInNum(new BigDecimal(0)); | 
 |  |  |         data.setLastInNum(new BigDecimal(0)); | 
 |  |  |         data.setSameInNum(new BigDecimal(0)); | 
 |  |  |         //---------省外---------------- | 
 |  |  |         data.setCurrentOutYearNum(new BigDecimal(0)); | 
 |  |  |         data.setCurrentOutWeekNum(new BigDecimal(0)); | 
 |  |  |         data.setCurrentOutMonthNum(new BigDecimal(0)); | 
 |  |  |         data.setLastOutYearNum(new BigDecimal(0)); | 
 |  |  |         data.setLastOutMonthNum(new BigDecimal(0)); | 
 |  |  |         data.setLastOutWeekNum(new BigDecimal(0)); | 
 |  |  |         data.setSameOutMonthNum(new BigDecimal(0)); | 
 |  |  |         data.setCurrentOutNum(new BigDecimal(0)); | 
 |  |  |         data.setLastOutNum(new BigDecimal(0)); | 
 |  |  |         data.setSameOutNum(new BigDecimal(0)); | 
 |  |  |  | 
 |  |  |         Date sameStart = DateUtil.getBeginDayOfMonth(-1); | 
 |  |  |         Date sameEnd = DateUtil.getEndDayOfMonth(-1); | 
 |  |  |         Date curStart = DateUtil.getBeginDayOfMonth(0); | 
 |  |  |         Date curEnd = DateUtil.getEndDayOfMonth(0); | 
 |  |  |         Date lastStart = DateUtil.getBeginDayOfLastMonth(); | 
 |  |  |         Date lastEnd = DateUtil.getEndDayOfLastMonth(); | 
 |  |  |         if(type ==1){ | 
 |  |  |             //本周 | 
 |  |  |             sameStart= DateUtil.getBeginDayOfWeek(-1); | 
 |  |  |             sameEnd= DateUtil.getEndDayOfWeek(-1); | 
 |  |  |             curStart= DateUtil.getBeginDayOfWeek(0); | 
 |  |  |             curEnd= DateUtil.getEndDayOfWeek(0); | 
 |  |  |             lastStart = DateUtil.getBeginDayOfLastWeek(); | 
 |  |  |             lastEnd= DateUtil.getEndDayOfLastWeek(); | 
 |  |  |         }else if(type == 2){ | 
 |  |  |             curStart= DateUtil.getBeginDayOfYear(0); | 
 |  |  |             curEnd= DateUtil.getEndDayOfYear(0); | 
 |  |  |             lastStart= DateUtil.getBeginDayOfYear(-1); | 
 |  |  |             lastEnd= DateUtil.getEndDayOfYear(-1); | 
 |  |  |             sameStart = null; | 
 |  |  |             sameEnd =null; | 
 |  |  |         } | 
 |  |  |         TmsOutQtyAndVehicleQtyRequest param = new TmsOutQtyAndVehicleQtyRequest(); | 
 |  |  |         if(StringUtils.isNotBlank(code)){ | 
 |  |  |             param.setFacrotyCodeList(new ArrayList<>()); | 
 |  |  |             param.getFacrotyCodeList().add(code); | 
 |  |  |         } | 
 |  |  |         if(type !=2){ | 
 |  |  |             //本年的不需要查去年同周期 | 
 |  |  |             param.setDateEnd(DateUtil.getShortTime(sameEnd)); | 
 |  |  |             param.setDateStart(DateUtil.getShortTime(sameStart)); | 
 |  |  |             List<TmsOutQtyAndVehicleQtyResponse> listSame=  tmsService.getOutQtyAndVehicleQty(param);//去年同期 | 
 |  |  |             if(listSame!=null ){ | 
 |  |  |                 for(TmsOutQtyAndVehicleQtyResponse model : listSame){ | 
 |  |  |                     data.setSameOutNum(data.getSameOutNum().add(Constants.formatBigdecimal(model.getOutSideProvinceOutQty()))); | 
 |  |  |                     data.setSameInNum(data.getSameInNum().add(Constants.formatBigdecimal(model.getInSideProvinceOutQty()))); | 
 |  |  |                 } | 
 |  |  |             } | 
 |  |  |         } | 
 |  |  |         param.setDateEnd(DateUtil.getShortTime(curEnd)); | 
 |  |  |         param.setDateStart(DateUtil.getShortTime(curStart)); | 
 |  |  |         List<TmsOutQtyAndVehicleQtyResponse> listCur =  tmsService.getOutQtyAndVehicleQty(param);//本周期 | 
 |  |  |         if(listCur!=null ){ | 
 |  |  |             for(TmsOutQtyAndVehicleQtyResponse model : listCur){ | 
 |  |  |                 data.setCurrentOutNum(data.getCurrentOutNum().add(Constants.formatBigdecimal(model.getOutSideProvinceOutQty()))); | 
 |  |  |                 data.setCurrentInNum(data.getCurrentInNum().add(Constants.formatBigdecimal(model.getInSideProvinceOutQty()))); | 
 |  |  |                 data.setTotalCarNum(data.getTotalCarNum()+Constants.formatIntegerNum(model.getVehicleQty()));//累计车次 | 
 |  |  |             } | 
 |  |  |         } | 
 |  |  |         param.setDateEnd(DateUtil.getShortTime(lastEnd)); | 
 |  |  |         param.setDateStart(DateUtil.getShortTime(lastStart)); | 
 |  |  |         List<TmsOutQtyAndVehicleQtyResponse> listLast =  tmsService.getOutQtyAndVehicleQty(param);//上周期 | 
 |  |  |         if(listCur!=null ){ | 
 |  |  |             for(TmsOutQtyAndVehicleQtyResponse model : listLast){ | 
 |  |  |                 data.setLastOutNum(data.getLastOutNum().add(Constants.formatBigdecimal(model.getOutSideProvinceOutQty()))); | 
 |  |  |                 data.setLastInNum(data.getLastInNum().add(Constants.formatBigdecimal(model.getInSideProvinceOutQty()))); | 
 |  |  |             } | 
 |  |  |         } | 
 |  |  |         if(type == 2){//本年的 | 
 |  |  |             data.setSameOutNum(data.getLastOutNum()); | 
 |  |  |             data.setSameInNum(data.getLastInNum()); | 
 |  |  |         } | 
 |  |  |         return data; | 
 |  |  |     } | 
 |  |  |     /** | 
 |  |  | 
 |  |  |      * @return | 
 |  |  |      */ | 
 |  |  |     @Override | 
 |  |  |     public    List<WholeProvinceMapVO> mapYearAndMonthOutList(){ | 
 |  |  |     public    List<WholeProvinceMapVO> mapYearAndMonthOutList(String code){ | 
 |  |  |         List<WholeProvinceMapVO> result = new ArrayList<>(); | 
 |  |  |         List<TmsFactoryParam> paramList =factoryList(); | 
 |  |  |         if(paramList!=null && paramList.size()>0){ | 
 |  |  |             List<String> codes = new ArrayList<>(); | 
 |  |  |             for(TmsFactoryParam p : paramList){ | 
 |  |  |                 if(StringUtils.isBlank(p.getCode())){ | 
 |  |  |                     continue; | 
 |  |  |                 } | 
 |  |  |                 codes.add(p.getCode()); | 
 |  |  |             } | 
 |  |  |             if(codes.size()>0){ | 
 |  |  |                 TmsFacrotyCodeListRequest param = new TmsFacrotyCodeListRequest(); | 
 |  |  |                 param.setFacrotyCodeList(codes); | 
 |  |  |                 List<TmsDistributionOfDeliveryLocResponse> response  = tmsService.getDistributionOfDeliveryLocations(param);//查询出库量 | 
 |  |  |                 if(response!=null &&response.size()>0){ | 
 |  |  |                     for(TmsDistributionOfDeliveryLocResponse model : response){ | 
 |  |  |                         WholeProvinceMapVO tt = getFromProvinceResultList(model ,result); | 
 |  |  |                         if(tt == null){ | 
 |  |  |                             tt =new WholeProvinceMapVO(); | 
 |  |  |                             tt.setMonthNum( Constants.formatBigdecimal0Float(model.getMonthOutboundQuantity())); | 
 |  |  |                             tt.setYearNum( Constants.formatBigdecimal0Float(model.getYearOutboundQuantity())); | 
 |  |  |                             tt.setProvinceCode(model.getFromProvinceCode()); | 
 |  |  |                             tt.setProvinceName(model.getFromProvinceName()); | 
 |  |  |                             result.add(tt); | 
 |  |  |                         } | 
 |  |  |                     } | 
 |  |  |         TmsFacrotyCodeListRequest param = new TmsFacrotyCodeListRequest(); | 
 |  |  |         if(StringUtils.isNotBlank(code)){ | 
 |  |  |             param.setFacrotyCodeList(new ArrayList<>()); | 
 |  |  |             param.getFacrotyCodeList().add(code); | 
 |  |  |         } | 
 |  |  |         List<TmsDistributionOfDeliveryLocResponse> response  = tmsService.getDistributionOfDeliveryLocations(param);//查询出库量 | 
 |  |  |         if(response!=null &&response.size()>0){ | 
 |  |  |             for(TmsDistributionOfDeliveryLocResponse model : response){ | 
 |  |  |                 WholeProvinceMapVO tt = getFromProvinceResultList(model ,result); | 
 |  |  |                 if(tt == null){ | 
 |  |  |                     tt =new WholeProvinceMapVO(); | 
 |  |  |                     tt.setMonthNum( Constants.formatBigdecimal0Float(model.getMonthOutboundQuantity())); | 
 |  |  |                     tt.setYearNum( Constants.formatBigdecimal0Float(model.getYearOutboundQuantity())); | 
 |  |  |                     tt.setProvinceCode(model.getToProvinceCode()); | 
 |  |  |                     tt.setProvinceName(model.getToProvinceName()); | 
 |  |  |                     result.add(tt); | 
 |  |  |                 } | 
 |  |  |             } | 
 |  |  |  | 
 |  |  |         } | 
 |  |  |         return result; | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     private WholeProvinceMapVO getFromProvinceResultList(TmsDistributionOfDeliveryLocResponse model, List<WholeProvinceMapVO> result) { | 
 |  |  |         for(WholeProvinceMapVO t : result){ | 
 |  |  |             if(StringUtils.equals(t.getProvinceCode(), model.getFromProvinceCode())){ | 
 |  |  |             if(StringUtils.equals(t.getProvinceCode(), model.getToProvinceCode())){ | 
 |  |  |                 t.setMonthNum(Constants.formatBigdecimal(t.getMonthNum()).add(Constants.formatBigdecimal0Float(model.getMonthOutboundQuantity()))); | 
 |  |  |                 t.setYearNum(Constants.formatBigdecimal(t.getYearNum()).add(Constants.formatBigdecimal0Float(model.getYearOutboundQuantity()))); | 
 |  |  |                 return   t; | 
 |  |  | 
 |  |  |         return paramList; | 
 |  |  |     } | 
 |  |  |     /** | 
 |  |  |      * 获取未完成订单集合 | 
 |  |  |      * @return TmsBaseResponse | 
 |  |  |      */ | 
 |  |  |     @Override | 
 |  |  |     public   TmsBasePageResponse<TmsOrderNoFinishListResponse>  orderNoFinishList(TmsOrderNoFinishListRequest param){ | 
 |  |  |         TmsBasePageResponse<TmsOrderNoFinishListResponse> infoList =   tmsService.getNotFinishOrderList(param);//查询出库量 | 
 |  |  |      /*    if(infoList!=null && infoList.getRows()!=null){ | 
 |  |  |             for(TmsOrderNoFinishListResponse model :infoList.getRows()){ | 
 |  |  |                 model.setStatusDesc(TMSContants.TopStatusLevel.getNameByKey(TMSContants.ChildStatusLevel.getParentIndexByStatus(model.getStatus()))); | 
 |  |  |  | 
 |  |  |             } | 
 |  |  |         }*/ | 
 |  |  |         return infoList; | 
 |  |  |     } | 
 |  |  |     /** | 
 |  |  |      * 近七日到货情况 | 
 |  |  |      * @return | 
 |  |  |      */ | 
 |  |  |     @Override | 
 |  |  |     public  List<LastSevenDaysOrderVo> arriveGoodsList(String code){ | 
 |  |  |         List<LastSevenDaysOrderVo> list = new ArrayList<>(); | 
 |  |  |         TmsSevenArrivalDetailsRequest param = new TmsSevenArrivalDetailsRequest(); | 
 |  |  |         if(StringUtils.isNotBlank(code)){ | 
 |  |  |             param.setFacrotyCodeList(new ArrayList<>()); | 
 |  |  |             param.getFacrotyCodeList().add(code);//查询指定厂区 | 
 |  |  |         } | 
 |  |  |         Date date = new Date(); | 
 |  |  |         Date startDate = DateUtil.addDaysToDate(date,-7); | 
 |  |  |         //看板大屏近7日到货情况日期 0表示当天当前推7天,-1表示本月初1号-7号 | 
 |  |  |         String flag = systemDictDataBiz.queryByCode(Constants.TSM_PARAM,Constants.SCREEN_SEVENT_ARRIVAL_STARTDATE).getCode(); | 
 |  |  |         if(StringUtils.equals(flag,"-1")){ | 
 |  |  |             startDate =DateUtil.getBeginDayOfMonth(0); | 
 |  |  |             date = DateUtil.addDaysToDate(startDate,7); | 
 |  |  |         } | 
 |  |  |         param.setNcCreateDateFrom(DateUtil.getShortTime(startDate)); | 
 |  |  |         param.setNcCreateDateThrough(DateUtil.getShortTime(date)); | 
 |  |  |         List<TmsSevenArrivalStatusAndDetailsResponse> infoList =   tmsService.getSevenArrivalStatusAndDetails(param);//查询出库量 | 
 |  |  |         for (int i = 0; i < 7; i++) { | 
 |  |  |             LastSevenDaysOrderVo model = new LastSevenDaysOrderVo(); | 
 |  |  |             Date td = DateUtil.addDaysToDate(date,-i); | 
 |  |  |             model.setDateStr(DateUtil.getShortTime(td)); | 
 |  |  |             dealGoodsListFromResponse(model,infoList); | 
 |  |  |             list.add(model); | 
 |  |  |         } | 
 |  |  |         return list; | 
 |  |  |     } | 
 |  |  |     private void dealGoodsListFromResponse(  LastSevenDaysOrderVo model, List<TmsSevenArrivalStatusAndDetailsResponse> list) { | 
 |  |  |         model.setIngList(new ArrayList<>()); | 
 |  |  |         model.setWaitList(new ArrayList<>()); | 
 |  |  |         model.setDoneList(new ArrayList<>()); | 
 |  |  |         if(list ==null || list.size()==0){ | 
 |  |  |             return; | 
 |  |  |         } | 
 |  |  |         for(TmsSevenArrivalStatusAndDetailsResponse temp : list){ | 
 |  |  |             if(StringUtils.equals(temp.getNcCreateDate(),model.getDateStr())){ | 
 |  |  |                 if(Constants.equalsInteger(temp.getStatus(),Constants.ZERO)){ | 
 |  |  |                     model.getWaitList().add(temp); | 
 |  |  |                 }else if(Constants.equalsInteger(temp.getStatus(),Constants.ONE)){ | 
 |  |  |                     model.getIngList().add(temp); | 
 |  |  |                 }else if(Constants.equalsInteger(temp.getStatus(),Constants.TWO)){ | 
 |  |  |                     model.getDoneList().add(temp); | 
 |  |  |                 } | 
 |  |  |             } | 
 |  |  |         } | 
 |  |  |         model.setDoneNum(model.getDoneList().size()); | 
 |  |  |         model.setIngNum(model.getIngList().size()); | 
 |  |  |         model.setWaitNum(model.getWaitList().size()); | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     /** | 
 |  |  |      * 出库能力李永利 | 
 |  |  |      * @return | 
 |  |  |      */ |