|  |  | 
 |  |  |  | 
 |  |  | import com.alibaba.fastjson.JSONObject; | 
 |  |  | import com.alibaba.fastjson.TypeReference; | 
 |  |  | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; | 
 |  |  | import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; | 
 |  |  | import com.doumee.biz.system.SystemDictDataBiz; | 
 |  |  | import com.doumee.core.tms.model.TMSContants; | 
 |  |  | import com.doumee.core.tms.model.request.*; | 
 |  |  | import com.doumee.core.tms.model.response.*; | 
 |  |  | import com.doumee.core.utils.Constants; | 
 |  |  | import com.doumee.core.utils.DateUtil; | 
 |  |  | import com.doumee.core.utils.HttpsUtil; | 
 |  |  | import com.doumee.core.wms.model.request.*; | 
 |  |  | import com.doumee.core.wms.model.response.WmsBaseDataResponse; | 
 |  |  | import com.doumee.core.wms.model.response.WmsBaseResponse; | 
 |  |  | import com.doumee.core.wms.model.response.WmsInventoryDataResponse; | 
 |  |  | import com.doumee.dao.business.*; | 
 |  |  | import com.doumee.dao.business.dao.SmsEmailMapper; | 
 |  |  | import com.doumee.dao.business.model.*; | 
 |  |  | import com.doumee.service.business.impl.SmsEmailServiceImpl; | 
 |  |  | import com.doumee.service.business.third.TmsService; | 
 |  |  | import com.doumee.service.business.third.WmsService; | 
 |  |  | import com.github.yulichang.wrapper.MPJLambdaWrapper; | 
 |  |  | import io.swagger.models.auth.In; | 
 |  |  | import lombok.extern.slf4j.Slf4j; | 
 |  |  | import org.apache.commons.lang3.StringUtils; | 
 |  |  | import org.springframework.beans.factory.annotation.Autowired; | 
 |  |  | import org.springframework.beans.factory.annotation.Value; | 
 |  |  | import org.springframework.stereotype.Service; | 
 |  |  | import org.springframework.transaction.annotation.Transactional; | 
 |  |  |  | 
 |  |  | import java.util.*; | 
 |  |  |  | 
 |  |  | 
 |  |  |                 TmsCircleStatusResultListResponse t = new TmsCircleStatusResultListResponse(); | 
 |  |  |                 TMSContants.TopStatusLevel tem = TMSContants.TopStatusLevel.ddsc; | 
 |  |  |                 if(i == 0){ | 
 |  |  |                     tem=TMSContants.TopStatusLevel.ddsc; | 
 |  |  |                 } if(i == 1){ | 
 |  |  |                     tem=TMSContants.TopStatusLevel.ydpzz; | 
 |  |  |                 } if(i == 2){ | 
 |  |  |                     tem=TMSContants.TopStatusLevel.ckckz; | 
 |  |  |                 } if(i == 3){ | 
 |  |  |                     tem=TMSContants.TopStatusLevel.clysz; | 
 |  |  |                 } if(i == 4){ | 
 |  |  |                     tem=TMSContants.TopStatusLevel.ydh; | 
 |  |  |                 } if(i == 5){ | 
 |  |  |                     tem=TMSContants.TopStatusLevel.yrk; | 
 |  |  |                 } | 
 |  |  |                 if(i == 1){ | 
 |  |  |                     tem=TMSContants.TopStatusLevel.ydh; | 
 |  |  |                 } | 
 |  |  |                 if(i == 2){ | 
 |  |  |                     tem=TMSContants.TopStatusLevel.clysz; | 
 |  |  |                 } | 
 |  |  |                 if(i == 4){ | 
 |  |  |                     tem=TMSContants.TopStatusLevel.ckckz; | 
 |  |  |                 } | 
 |  |  |                 if(i == 3){ | 
 |  |  |                     tem=TMSContants.TopStatusLevel.ydpzz; | 
 |  |  |                 } | 
 |  |  |                 if(i == 5){ | 
 |  |  |                     tem=TMSContants.TopStatusLevel.ddsc; | 
 |  |  |                 } | 
 |  |  |                 t.setName(tem.getName()); | 
 |  |  |                 t.setKey(tem.getKey()); | 
 |  |  |                 t.setSecondList(getSecondCircleStatusList(tem,response.getData())); | 
 |  |  |                 list.add(t); | 
 |  |  |                 if(t.getSecondList()!=null & t.getSecondList().size()>0){ | 
 |  |  |                     list.add(t); | 
 |  |  |                 } | 
 |  |  |             } | 
 |  |  |         } | 
 |  |  |  | 
 |  |  |         Collections.sort(list, (o1, o2) -> { | 
 |  |  |             return o2.getKey()  -  o1.getKey(); //按数量从大到小排序 | 
 |  |  |         }); | 
 |  |  |         return list; | 
 |  |  |     } | 
 |  |  |  | 
 |  |  | 
 |  |  |         if(statusList!=null){ | 
 |  |  |             for(Integer t :statusList){ | 
 |  |  |                 for(TmsCircleStatusListResponse status :data){ | 
 |  |  |                     if(StringUtils.equals(status.getOrderStatus(),t.toString())){ | 
 |  |  |                     if(Constants.equalsInteger(status.getOrderStatus(),Constants.FOUR) | 
 |  |  |                             && Constants.equalsInteger(status.getType(),TMSContants.StatusCode.app)) { | 
 |  |  |                         status.setOrderStatus(TMSContants.ChildStatusLevel.clqdapp.getOrderStatus()); | 
 |  |  |                     } | 
 |  |  |                     if(Constants.equalsInteger(status.getOrderStatus(),Constants.FIVE) | 
 |  |  |                             && Constants.equalsInteger(status.getType(),TMSContants.StatusCode.app)) { | 
 |  |  |                         status.setOrderStatus(TMSContants.ChildStatusLevel.ddzhd.getOrderStatus()); | 
 |  |  |                     } | 
 |  |  |                     if(Constants.equalsInteger(status.getOrderStatus(),t )){ | 
 |  |  |                         status.setOrderStatusDes(TMSContants.ChildStatusLevel.getInfo(status.getOrderStatus(),null)); | 
 |  |  |                         list.add(status); | 
 |  |  |                     } | 
 |  |  |                     Date td =DateUtil.fromStringToDate("yyy-MM-dd HH:mm:ss",status.getRecordDate()); | 
 |  |  |                     if(td!=null){ | 
 |  |  |                         status.setTimeStamp(td.getTime()); | 
 |  |  |                     } | 
 |  |  |                 } | 
 |  |  |             } | 
 |  |  |         } | 
 |  |  |         Collections.sort(list, (o1, o2) -> { | 
 |  |  |             return (int) (o2.getTimeStamp() - o1.getTimeStamp()); //按数量从大到小排序 | 
 |  |  |         }); | 
 |  |  |         return list; | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     /** | 
 |  |  |      * 未完成订单列表接口 | 
 |  |  |      * 根据区域ID集合+筛选条件(合同号、制单开始日期、制单结束日期、发货地、到货地、省份,非需要),返回合同列表信息,按照时间倒序展示; | 
 |  |  |      * @param param 参数 | 
 |  |  |      * @return TmsBaseResponse | 
 |  |  |      */ | 
 |  |  |     @Override | 
 |  |  |     public    TmsBasePageResponse<TmsOrderNoFinishListResponse> getNotFinishOrderList(TmsOrderNoFinishListRequest param){ | 
 |  |  |         String url = systemDictDataBiz.queryByCode(Constants.TSM_PARAM,Constants.TMS_INTERFACE_URL_PREFIX).getCode() | 
 |  |  |                     +TMSContants.InterfacePath.getNotFinishOrderList[0]; | 
 |  |  |         TmsBaseResponse<TmsBasePageResponse<TmsOrderNoFinishListResponse> > response = sendHttpRequest(url,TMSContants.InterfacePath.getNotFinishOrderList[1],JSONObject.toJSONString(param) | 
 |  |  |                 ,new TypeReference< TmsBaseResponse<TmsBasePageResponse<TmsOrderNoFinishListResponse>> >(){}); | 
 |  |  |         if(response ==null || response.getData() == null){ | 
 |  |  |             return  new TmsBasePageResponse<>(); | 
 |  |  |         } | 
 |  |  |         return  response.getData(); | 
 |  |  |  | 
 |  |  |     } | 
 |  |  |     /** | 
 |  |  |      * 出库能力统计 | 
 |  |  |      * 查询某个厂/全部厂的今日计划量、今日出库量、今日未出库量数据。 | 
 |  |  |      * @param param 参数 | 
 |  |  |      * @return TmsBaseResponse | 
 |  |  |      */ | 
 |  |  |     @Override | 
 |  |  |     public    TmsOutboundCapabilityResponse getOutboundCapability(TmsFacrotyCodeListRequest param){ | 
 |  |  |         String url = systemDictDataBiz.queryByCode(Constants.TSM_PARAM,Constants.TMS_INTERFACE_URL_PREFIX).getCode() | 
 |  |  |                     +TMSContants.InterfacePath.getOutboundCapability[0]; | 
 |  |  |         TmsBaseResponse<TmsOutboundCapabilityResponse > response = sendHttpRequest(url,TMSContants.InterfacePath.getOutboundCapability[1],JSONObject.toJSONString(param) | 
 |  |  |                 ,new TypeReference< TmsBaseResponse<TmsOutboundCapabilityResponse>>(){}); | 
 |  |  |         if(response ==null || response.getData() == null){ | 
 |  |  |             return  new TmsOutboundCapabilityResponse(); | 
 |  |  |         } | 
 |  |  |         return  response.getData(); | 
 |  |  |     } | 
 |  |  |     /** | 
 |  |  |      * 合同列表接口 | 
 |  |  |      * 根据区域ID集合+筛选条件(合同号、制单开始日期、制单结束日期、发货地、到货地、省份,非需要),返回合同列表信息,按照时间倒序展示; | 
 |  |  | 
 |  |  |      * @return TmsBaseResponse | 
 |  |  |      */ | 
 |  |  |     @Override | 
 |  |  |     public   List<TmsOrderListResponse>  orderList(TmsOrderListRequest param){ | 
 |  |  |        if(StringUtils.isBlank(param.getPhoneNumber())){ | 
 |  |  |            param.setPhoneNumber("00000000000");//手机号必填 | 
 |  |  |        } | 
 |  |  |        if(param.getContractNumbers()==null || param.getContractNumbers().size()==0){ | 
 |  |  |            param.setContractNumbers(null); | 
 |  |  |        } | 
 |  |  |     public   TmsBasePageResponse<TmsOrderListResponse>  orderList(TmsOrderListRequest param){ | 
 |  |  |         String url = systemDictDataBiz.queryByCode(Constants.TSM_PARAM,Constants.TMS_INTERFACE_URL_PREFIX).getCode() | 
 |  |  |                     +TMSContants.InterfacePath.getOrderList[0]; | 
 |  |  |         TmsBaseResponse<List<TmsOrderListResponse>> response = sendHttpRequest(url,TMSContants.InterfacePath.getOrderList[1],JSONObject.toJSONString(param) | 
 |  |  |                 ,new TypeReference< TmsBaseResponse<List<TmsOrderListResponse>>>(){}); | 
 |  |  |         TmsBaseResponse<TmsBasePageResponse<TmsOrderListResponse>> response = sendHttpRequest(url,TMSContants.InterfacePath.getOrderList[1],JSONObject.toJSONString(param) | 
 |  |  |                 ,new TypeReference< TmsBaseResponse<TmsBasePageResponse<TmsOrderListResponse>>>(){}); | 
 |  |  |         if(response ==null){ | 
 |  |  |             return  new ArrayList<>(); | 
 |  |  |             return  new TmsBasePageResponse<>(); | 
 |  |  |         }else{ | 
 |  |  |             return response.getData()==null?new ArrayList<>():response.getData(); | 
 |  |  |             return response.getData()==null?new TmsBasePageResponse<>():response.getData(); | 
 |  |  |         } | 
 |  |  |     } | 
 |  |  |     /** | 
 |  |  | 
 |  |  |         } | 
 |  |  |         String url = systemDictDataBiz.queryByCode(Constants.TSM_PARAM,Constants.TMS_INTERFACE_URL_PREFIX).getCode() | 
 |  |  |                     +TMSContants.InterfacePath.getOrderDetailByContractNumber[0]; | 
 |  |  |         TmsBaseResponse<TmsOrderInfoResponse> response = sendHttpRequest(url,TMSContants.InterfacePath.getOrderDetailByContractNumber[1],JSONObject.toJSONString(param) | 
 |  |  |         TmsBaseResponse<TmsOrderInfoResponse> response = sendHttpRequest(url,TMSContants.InterfacePath.getOrderDetailByContractNumber[1] | 
 |  |  |                 ,param.getContractNumber() | 
 |  |  |                 ,new TypeReference< TmsBaseResponse<TmsOrderInfoResponse>>(){}); | 
 |  |  |         if(response!=null && response.getData()!=null){ | 
 |  |  |               result =response.getData(); | 
 |  |  | 
 |  |  |         result.setCicleStatusList(getCicleStatusList(p1)); | 
 |  |  |         return result; | 
 |  |  |     } | 
 |  |  |     /** | 
 |  |  |      * 全国到货地分布查询查询 | 
 |  |  |      * @param param 参数 | 
 |  |  |      * @return TmsBaseResponse | 
 |  |  |      */ | 
 |  |  |     @Override | 
 |  |  |     public  List<TmsDistributionOfDeliveryLocResponse>   getDistributionOfDeliveryLocations(TmsFacrotyCodeListRequest param){ | 
 |  |  |         List<TmsDistributionOfDeliveryLocResponse> result = new ArrayList<>(); | 
 |  |  | //        if( param.getFacrotyCodeList() == null || param.getFacrotyCodeList().size() == 0){ | 
 |  |  | //            param.setFacrotyCodeList(new ArrayList<>()); | 
 |  |  | //            param.getFacrotyCodeList().add("0"); | 
 |  |  | //        } | 
 |  |  |         String url = systemDictDataBiz.queryByCode(Constants.TSM_PARAM,Constants.TMS_INTERFACE_URL_PREFIX).getCode() | 
 |  |  |                     +TMSContants.InterfacePath.getDistributionOfDeliveryLocations[0]; | 
 |  |  |         TmsBaseResponse< List<TmsDistributionOfDeliveryLocResponse>> response = sendHttpRequest(url,TMSContants.InterfacePath.getDistributionOfDeliveryLocations[1], | 
 |  |  |                 JSONObject.toJSONString(param) | 
 |  |  |                 ,new TypeReference< TmsBaseResponse< List<TmsDistributionOfDeliveryLocResponse>>>(){}); | 
 |  |  |         if(response!=null && response.getData()!=null){ | 
 |  |  |               result =response.getData(); | 
 |  |  |         } | 
 |  |  |  | 
 |  |  |         return result; | 
 |  |  |     } | 
 |  |  |     /** | 
 |  |  |      * 实时库存查询 | 
 |  |  |      * @return TmsBaseResponse | 
 |  |  |      */ | 
 |  |  |     @Override | 
 |  |  |     public  List<TmsInventoryListResponse>   getRealTimeInventory( ){ | 
 |  |  |         List<TmsInventoryListResponse> result = new ArrayList<>(); | 
 |  |  |         String url = systemDictDataBiz.queryByCode(Constants.TSM_PARAM,Constants.TMS_INTERFACE_URL_PREFIX).getCode() | 
 |  |  |                     +TMSContants.InterfacePath.getRealTimeInventory[0]; | 
 |  |  |         TmsBaseResponse< List<TmsInventoryListResponse>> response = sendHttpRequest(url,TMSContants.InterfacePath.getRealTimeInventory[1] | 
 |  |  |                 ,"{}" | 
 |  |  |                 ,new TypeReference< TmsBaseResponse< List<TmsInventoryListResponse>>>(){}); | 
 |  |  |         if(response!=null && response.getData()!=null){ | 
 |  |  |               result =response.getData(); | 
 |  |  |         } | 
 |  |  |  | 
 |  |  |         return result; | 
 |  |  |     } | 
 |  |  |     /** | 
 |  |  |      * 查询5个厂的运力资源利用情况 | 
 |  |  |      * @return TmsBaseResponse | 
 |  |  |      */ | 
 |  |  |     @Override | 
 |  |  |     public  List<TmsTotalAndReportVehicleQtyResponse>   getTotalAndReportVehicleQty( ){ | 
 |  |  |         List<TmsTotalAndReportVehicleQtyResponse> result = new ArrayList<>(); | 
 |  |  |         String url = systemDictDataBiz.queryByCode(Constants.TSM_PARAM,Constants.TMS_INTERFACE_URL_PREFIX).getCode() | 
 |  |  |                     +TMSContants.InterfacePath.getTotalAndReportVehicleQty[0]; | 
 |  |  |         TmsBaseResponse< List<TmsTotalAndReportVehicleQtyResponse>> response = sendHttpRequest(url,TMSContants.InterfacePath.getTotalAndReportVehicleQty[1] | 
 |  |  |                 ,"{}" | 
 |  |  |                 ,new TypeReference< TmsBaseResponse< List<TmsTotalAndReportVehicleQtyResponse>>>(){}); | 
 |  |  |         if(response!=null && response.getData()!=null){ | 
 |  |  |               result =response.getData(); | 
 |  |  |         } | 
 |  |  |  | 
 |  |  |         return result; | 
 |  |  |     } | 
 |  |  |     /** | 
 |  |  |      * 近7日到货情况(含明细) | 
 |  |  |      * @return TmsBaseResponse | 
 |  |  |      */ | 
 |  |  |     @Override | 
 |  |  |     public  List<TmsSevenArrivalStatusAndDetailsResponse>   getSevenArrivalStatusAndDetails(TmsSevenArrivalDetailsRequest param ){ | 
 |  |  |         List<TmsSevenArrivalStatusAndDetailsResponse> result = new ArrayList<>(); | 
 |  |  |         String url = systemDictDataBiz.queryByCode(Constants.TSM_PARAM,Constants.TMS_INTERFACE_URL_PREFIX).getCode() | 
 |  |  |                     +TMSContants.InterfacePath.getSevenArrivalStatusAndDetails[0]; | 
 |  |  |         TmsBaseResponse< List<TmsSevenArrivalStatusAndDetailsResponse>> response = sendHttpRequest(url,TMSContants.InterfacePath.getSevenArrivalStatusAndDetails[1] | 
 |  |  |                 ,JSONObject.toJSONString(param) | 
 |  |  |                 ,new TypeReference< TmsBaseResponse< List<TmsSevenArrivalStatusAndDetailsResponse>>>(){}); | 
 |  |  |         if(response!=null && response.getData()!=null){ | 
 |  |  |               result =response.getData(); | 
 |  |  |         } | 
 |  |  |         return result; | 
 |  |  |     } | 
 |  |  |     /** | 
 |  |  |      * 指定时间范围内累计出库量 | 
 |  |  |      * @return TmsBaseResponse | 
 |  |  |      */ | 
 |  |  |     @Override | 
 |  |  |     public  List<TmsOutQtyAndVehicleQtyResponse>   getOutQtyAndVehicleQty(TmsOutQtyAndVehicleQtyRequest param ){ | 
 |  |  |         List<TmsOutQtyAndVehicleQtyResponse> result = new ArrayList<>(); | 
 |  |  |         String url = systemDictDataBiz.queryByCode(Constants.TSM_PARAM,Constants.TMS_INTERFACE_URL_PREFIX).getCode() | 
 |  |  |                     +TMSContants.InterfacePath.getOutQtyAndVehicleQty[0]; | 
 |  |  |         TmsBaseResponse< List<TmsOutQtyAndVehicleQtyResponse>> response = sendHttpRequest(url,TMSContants.InterfacePath.getOutQtyAndVehicleQty[1] | 
 |  |  |                 ,JSONObject.toJSONString(param) | 
 |  |  |                 ,new TypeReference< TmsBaseResponse< List<TmsOutQtyAndVehicleQtyResponse>>>(){}); | 
 |  |  |         if(response!=null && response.getData()!=null){ | 
 |  |  |               result =response.getData(); | 
 |  |  |         } | 
 |  |  |         return result; | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |  | 
 |  |  |     /** | 
 |  |  |      * 发起 tms接口请求 |