|  |  | 
 |  |  | 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.SmsConfigMapper; | 
 |  |  | 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.EmayService; | 
 |  |  | import com.doumee.service.business.third.WmsService; | 
 |  |  | 
 |  |  | import org.springframework.beans.factory.annotation.Autowired; | 
 |  |  | import org.springframework.stereotype.Service; | 
 |  |  | import org.springframework.transaction.annotation.Transactional; | 
 |  |  | import org.springframework.util.CollectionUtils; | 
 |  |  |  | 
 |  |  | import java.util.*; | 
 |  |  | import java.util.stream.Collectors; | 
 |  |  |  | 
 |  |  | /** | 
 |  |  |  * WMS平台对接Service实现 | 
 |  |  | 
 |  |  |     private SmsEmailMapper smsEmailMapper; | 
 |  |  |     @Autowired | 
 |  |  |     private EmayService emayService; | 
 |  |  |     @Autowired | 
 |  |  |     private RetentionMapper retentionMapper; | 
 |  |  |     /** | 
 |  |  |      * 入库通知任务业务处理 | 
 |  |  |      * @param job 参数 | 
 |  |  | 
 |  |  |         } | 
 |  |  |         WmsOrderPlatformRequest  param  = new WmsOrderPlatformRequest(); | 
 |  |  |          param.setData(new ArrayList<>()); | 
 |  |  |          WmsOrderPlatformInfoRequest o = new WmsOrderPlatformInfoRequest(); | 
 |  |  |          o.setCarrierBillCode(job.getBillCode()); | 
 |  |  |          o.setRailwayNo(job.getPlatformWmsCode()); | 
 |  |  |          param.getData().add(o); | 
 |  |  |  | 
 |  |  |         List<PlatformWmsDetail> platformWmsDetailList = platformWmsDetailMapper.selectList(new QueryWrapper<PlatformWmsDetail>().lambda() | 
 |  |  |                 .eq(PlatformWmsDetail::getJobId,job.getId()) | 
 |  |  |                 .eq(PlatformWmsDetail::getIsdeleted,Constants.ZERO) | 
 |  |  |         ); | 
 |  |  |         if(com.github.xiaoymin.knife4j.core.util.CollectionUtils.isNotEmpty(platformWmsDetailList)){ | 
 |  |  |             for (PlatformWmsDetail platformWmsDetail:platformWmsDetailList) { | 
 |  |  |                 if(StringUtils.isNotBlank(platformWmsDetail.getIocode())){ | 
 |  |  |                     WmsOrderPlatformInfoRequest o = new WmsOrderPlatformInfoRequest(); | 
 |  |  |                     o.setCarrierBillCode(platformWmsDetail.getIocode()); | 
 |  |  |                     o.setRailwayNo(job.getPlatformWmsCode()); | 
 |  |  |                     param.getData().add(o); | 
 |  |  |                 } | 
 |  |  |             } | 
 |  |  |         } | 
 |  |  |  | 
 |  |  |          String url = type == 0?systemDictDataBiz.queryByCode(Constants.WMS_PARAM,Constants.WMS_INBOUND_PLATFROM_URL).getCode(): | 
 |  |  |                  systemDictDataBiz.queryByCode(Constants.WMS_PARAM,Constants.WMS_OUTBOUND_PLATFROM_URL).getCode();; | 
 |  |  |          String name = type ==0?"【WMS】入库作业单分配月台":"【WMS】出库作业的分配月台"; | 
 |  |  | 
 |  |  |             //如果是自有物流车 | 
 |  |  |             job.setType(type==0?Constants.platformJobType.zycxh:Constants.platformJobType.zyczh);//自有车卸货/装货 | 
 |  |  |             job.setCarCodeBack(job.getCarCodeFront());//自有车默认前后车牌一样 | 
 |  |  |             if(Constants.equalsInteger(car.getInStatus(),Constants.ONE) && car.getJobNum() == 0) { | 
 |  |  |             if(retentionMapper.selectCount(new QueryWrapper<Retention>().lambda().eq(Retention::getType,Constants.THREE) | 
 |  |  |                     .eq(Retention::getCarNo,car.getCode()))>Constants.ZERO && car.getJobNum() == 0){ | 
 |  |  |                 //如果车辆在园 | 
 |  |  |                 job.setStatus(Constants.PlatformJobStatus.WAIT_CALL.getKey());//在园无作业状态,则自动【已签到】处理 | 
 |  |  |                 job.setArriveDate(new Date()); | 
 |  |  |                 job.setSingType(Constants.TWO); | 
 |  |  |                 job.setSignDate(new Date()); | 
 |  |  |                 List<PlatformJob> signList = platformJobMapper.selectList(new QueryWrapper<PlatformJob>(). | 
 |  |  |                         lambda().apply(" DATE(SIGN_DATE) = DATE(NOW()) and sign_date is not null  ") | 
 |  |  |                 ); | 
 |  |  |                 if(CollectionUtils.isEmpty(signList)){ | 
 |  |  |                     job.setSignNum(Constants.ONE); | 
 |  |  |                 } else{ | 
 |  |  |                     int maxNumber = Collections.max(signList.stream().map(i->i.getSignNum()).collect(Collectors.toList())); | 
 |  |  |                     job.setSignNum(maxNumber + Constants.ONE); | 
 |  |  |                 } | 
 |  |  |             } | 
 |  |  |         } | 
 |  |  |         PlatformGroup group = platformGroupMapper.selectOne(new QueryWrapper<PlatformGroup>().lambda() | 
 |  |  | 
 |  |  |                     .set(PlatformWmsDetail::getStatus,Constants.TWO) | 
 |  |  |                     .in(PlatformWmsDetail::getIocode,iocodeList) | 
 |  |  |                     .eq(PlatformWmsDetail::getIsdeleted, Constants.ZERO)); | 
 |  |  |              | 
 |  |  |             platformWmsJobMapper.update(null,new UpdateWrapper<PlatformWmsJob>().lambda() | 
 |  |  |                     .set(PlatformWmsJob::getStatus,Constants.TWO) | 
 |  |  |                     .in(PlatformWmsJob::getIocode,iocodeList) | 
 |  |  |                     .eq(PlatformWmsJob::getIsdeleted, Constants.ZERO)); | 
 |  |  |  | 
 |  |  |             List<PlatformWmsJob> platformWmsJob = platformWmsJobMapper.selectList(new QueryWrapper<PlatformWmsJob>().lambda() | 
 |  |  |                     .in(PlatformWmsJob::getIocode,iocodeList) | 
 |  |  |                     .eq(PlatformWmsJob::getIsdeleted, Constants.ZERO) | 
 |  |  |             ); | 
 |  |  |             if(com.github.xiaoymin.knife4j.core.util.CollectionUtils.isNotEmpty(platformWmsJob)){ | 
 |  |  |                 List<Integer> jobIds = platformWmsJob.stream().filter(i->Objects.nonNull(i.getJobId())).map(i->i.getJobId()).collect(Collectors.toList()); | 
 |  |  |                 if(com.github.xiaoymin.knife4j.core.util.CollectionUtils.isNotEmpty(jobIds)){ | 
 |  |  |                     Set<Integer> setJobIds = new HashSet<>(jobIds); | 
 |  |  |                     platformJobMapper.update(null,new UpdateWrapper<PlatformJob>() | 
 |  |  |                             .lambda() | 
 |  |  |                             .set(PlatformJob::getStatus,Constants.PlatformJobStatus.CANCEL.getKey()) | 
 |  |  |                             .in(PlatformJob::getId,setJobIds) | 
 |  |  |                     ); | 
 |  |  |                     for (Integer jobId:setJobIds | 
 |  |  |                     ) { | 
 |  |  |                         SmsEmailServiceImpl.sendPlatformJobSms(systemDictDataBiz, | 
 |  |  |                                 emayService,smsEmailMapper,smsConfigMapper,platformJobMapper,jobId, | 
 |  |  |                                 SmsConstants.platformJobContent.platformJobStopJob,null,null | 
 |  |  |                         ); | 
 |  |  |                     } | 
 |  |  |                 } | 
 |  |  |             } | 
 |  |  |  | 
 |  |  |         }catch (Exception e){ | 
 |  |  |             log.error("【WMS】处理入库取消通知业务===============业务处理异常"+e.getMessage()); | 
 |  |  |             return returnFailReuslt("业务处理异常"); | 
 |  |  | 
 |  |  |                     .set(PlatformWmsDetail::getStatus,Constants.TWO) | 
 |  |  |                     .in(PlatformWmsDetail::getIocode,iocodeList) | 
 |  |  |                     .eq(PlatformWmsDetail::getIsdeleted, Constants.ZERO)); | 
 |  |  |  | 
 |  |  |             platformWmsJobMapper.update(null,new UpdateWrapper<PlatformWmsJob>().lambda() | 
 |  |  |                     .set(PlatformWmsJob::getStatus,Constants.TWO) | 
 |  |  |                     .in(PlatformWmsJob::getIocode,iocodeList) | 
 |  |  |                     .eq(PlatformWmsJob::getIsdeleted, Constants.ZERO)); | 
 |  |  |  | 
 |  |  |             List<PlatformWmsJob> platformWmsJob = platformWmsJobMapper.selectList(new QueryWrapper<PlatformWmsJob>().lambda() | 
 |  |  |                     .in(PlatformWmsJob::getIocode,iocodeList) | 
 |  |  |                     .eq(PlatformWmsJob::getIsdeleted, Constants.ZERO) | 
 |  |  |             ); | 
 |  |  |             if(com.github.xiaoymin.knife4j.core.util.CollectionUtils.isNotEmpty(platformWmsJob)){ | 
 |  |  |                 List<Integer> jobIds = platformWmsJob.stream().filter(i->Objects.nonNull(i.getJobId())).map(i->i.getJobId()).collect(Collectors.toList()); | 
 |  |  |                 if(com.github.xiaoymin.knife4j.core.util.CollectionUtils.isNotEmpty(jobIds)){ | 
 |  |  |                     Set<Integer> setJobIds = new HashSet<>(jobIds); | 
 |  |  |                     platformJobMapper.update(null,new UpdateWrapper<PlatformJob>() | 
 |  |  |                             .lambda() | 
 |  |  |                             .set(PlatformJob::getStatus,Constants.PlatformJobStatus.CANCEL.getKey()) | 
 |  |  |                             .in(PlatformJob::getId,setJobIds) | 
 |  |  |                     ); | 
 |  |  |                     for (Integer jobId:setJobIds | 
 |  |  |                          ) { | 
 |  |  |                         SmsEmailServiceImpl.sendPlatformJobSms(systemDictDataBiz, | 
 |  |  |                                 emayService,smsEmailMapper,smsConfigMapper,platformJobMapper,jobId, | 
 |  |  |                                 SmsConstants.platformJobContent.platformJobStopJob,null,null | 
 |  |  |                         ); | 
 |  |  |                     } | 
 |  |  |                 } | 
 |  |  |             } | 
 |  |  |  | 
 |  |  |  | 
 |  |  |         }catch (Exception e){ | 
 |  |  |             log.error("【WMS】出库取消通知任务业务处理===============业务处理异常"+e.getMessage()); | 
 |  |  |             return returnFailReuslt("业务处理异常"); |