|  |  |  | 
|---|
|  |  |  | import com.doumee.core.model.LoginUserInfo; | 
|---|
|  |  |  | import com.doumee.core.model.PageData; | 
|---|
|  |  |  | import com.doumee.core.model.PageWrap; | 
|---|
|  |  |  | import com.doumee.core.tms.model.request.TmsLockStatusQueryRequest; | 
|---|
|  |  |  | import com.doumee.core.tms.model.response.TmsBaseResponse; | 
|---|
|  |  |  | import com.doumee.core.tms.model.response.TmsLockStatusQueryResponse; | 
|---|
|  |  |  | import com.doumee.core.utils.*; | 
|---|
|  |  |  | import com.doumee.dao.business.*; | 
|---|
|  |  |  | import com.doumee.dao.business.join.PlatformJobJoinMapper; | 
|---|
|  |  |  | 
|---|
|  |  |  | import com.doumee.service.business.impl.hksync.HkSyncPushServiceImpl; | 
|---|
|  |  |  | import com.doumee.service.business.impl.thrid.WmsServiceImpl; | 
|---|
|  |  |  | import com.doumee.service.business.third.EmayService; | 
|---|
|  |  |  | import com.doumee.service.business.third.TmsService; | 
|---|
|  |  |  | import com.doumee.service.business.third.WmsService; | 
|---|
|  |  |  | import com.github.yulichang.wrapper.MPJLambdaWrapper; | 
|---|
|  |  |  | import lombok.extern.slf4j.Slf4j; | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private PlatformJobMapper platformJobMapper; | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private TmsService tmsService; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private PlatformDeviceMapper platformDeviceMapper; | 
|---|
|  |  |  | 
|---|
|  |  |  | " ( " + | 
|---|
|  |  |  | " ( t.`STATUS` = "+Constants.PlatformJobStatus.WAIT_CALL.getKey()+" and t.PLATFORM_GROUP_ID = ( SELECT p.group_id FROM platform p WHERE p.id = "+pageWrap.getModel().getPlatformId()+" LIMIT 1 )  )" + | 
|---|
|  |  |  | " or  " + | 
|---|
|  |  |  | " (t.`STATUS` = "+Constants.PlatformJobStatus.IN_WAIT.getKey()+" )" + | 
|---|
|  |  |  | " (t.`STATUS` = "+Constants.PlatformJobStatus.IN_WAIT.getKey()+" and t.PLATFORM_GROUP_ID = ( SELECT p.group_id FROM platform p WHERE p.id = "+pageWrap.getModel().getPlatformId()+" LIMIT 1 )  )" + | 
|---|
|  |  |  | " or " + | 
|---|
|  |  |  | "  (t.`STATUS` = "+Constants.PlatformJobStatus.TRANSFERING.getKey()+" and t.PLATFORM_ID = "+pageWrap.getModel().getPlatformId()+" )  " + | 
|---|
|  |  |  | ") " | 
|---|
|  |  |  | 
|---|
|  |  |  | ); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | platformJob.setPlatformName(platform.getName()); | 
|---|
|  |  |  | this.broadcastAndLEed(platformJob, StringUtils.isBlank(oldPlatform.getRemark())?Constants.PlatformLedContent.IDEL_CONTNET.getName():oldPlatform.getLedContent(), | 
|---|
|  |  |  | this.broadcastAndLEed(platformJob, StringUtils.isBlank(oldPlatform.getLedContent())?Constants.PlatformLedContent.IDEL_CONTNET.getName():oldPlatform.getLedContent(), | 
|---|
|  |  |  | null | 
|---|
|  |  |  | ); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  | emayService,smsEmailMapper,smsConfigMapper,platformJobMapper,platformJob.getId(), | 
|---|
|  |  |  | SmsConstants.platformJobContent.platformJobError,platform.getName(),null | 
|---|
|  |  |  | ); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | platformJob.setPlatformName(platform.getName()); | 
|---|
|  |  |  | this.broadcastAndLEed(platformJob, StringUtils.isBlank(platform.getLedContent())?Constants.PlatformLedContent.IDEL_CONTNET.getName():platform.getLedContent(), | 
|---|
|  |  |  | null | 
|---|
|  |  |  | ); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  | savePlatformLog(Constants.PlatformJobLogType.DONE.getKey(),oldPlatformJob,platformJob , | 
|---|
|  |  |  | Constants.PlatformJobLogType.DONE.getInfo()); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if(Constants.equalsInteger(platformJob.getType(),Constants.TWO)){ | 
|---|
|  |  |  | //TODO 外协车装货 查询TMS 电子锁情况 | 
|---|
|  |  |  | if(Constants.equalsInteger(platformJob.getType(),Constants.THREE)){ | 
|---|
|  |  |  | // 外协车装货 查询TMS 电子锁情况 | 
|---|
|  |  |  | List<PlatformWmsDetail> details = platformWmsDetailMapper.selectList(new QueryWrapper<PlatformWmsDetail>().lambda() | 
|---|
|  |  |  | .eq(PlatformWmsDetail::getJobId,platformJob.getId()) | 
|---|
|  |  |  | .eq(PlatformWmsDetail::getIsdeleted,Constants.ZERO) | 
|---|
|  |  |  | ); | 
|---|
|  |  |  | if(details!=null && details.size()>0){ | 
|---|
|  |  |  | Date date = new Date(); | 
|---|
|  |  |  | List<String> codeList =new ArrayList<>(); | 
|---|
|  |  |  | for(PlatformWmsDetail d : details){ | 
|---|
|  |  |  | codeList.add(d.getIocode()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | TmsLockStatusQueryRequest tmsLock = new TmsLockStatusQueryRequest(); | 
|---|
|  |  |  | tmsLock.setContractNumbers(codeList); | 
|---|
|  |  |  | TmsBaseResponse<List<TmsLockStatusQueryResponse>>  lockResult =  tmsService.lockStatusQuery(tmsLock); | 
|---|
|  |  |  | if(lockResult!=null && lockResult.isSuccess()&& lockResult.getData()!=null ){ | 
|---|
|  |  |  | for(TmsLockStatusQueryResponse s : lockResult.getData()){ | 
|---|
|  |  |  | platformWmsDetailMapper.update(null,new UpdateWrapper<PlatformWmsDetail>().lambda() | 
|---|
|  |  |  | .eq(PlatformWmsDetail::getIocode,s.getContractNumber()) | 
|---|
|  |  |  | .set(PlatformWmsDetail::getEditDate,date) | 
|---|
|  |  |  | .set(PlatformWmsDetail::getLockDate,s.getOutDate()) | 
|---|
|  |  |  | .set(PlatformWmsDetail::getLockStatus,Constants.ONE) | 
|---|
|  |  |  | .eq(PlatformWmsDetail::getJobId,platformJob.getId()) | 
|---|
|  |  |  | .eq(PlatformWmsDetail::getIsdeleted,Constants.ZERO)); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | }else if(Constants.equalsInteger(platformJob.getType(),Constants.ONE) || Constants.equalsInteger(platformJob.getType(),Constants.FOUR)){ | 
|---|
|  |  |  | //TODO 外协车卸货 或者 市公司车卸货 则根据任务情况 | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //发送短信信息 | 
|---|
|  |  |  | SmsEmailServiceImpl.sendPlatformJobSms(systemDictDataBiz, | 
|---|
|  |  |  | emayService,smsEmailMapper,smsConfigMapper,platformJobMapper,platformJob.getId(), | 
|---|
|  |  |  | SmsConstants.platformJobContent.platformJobFinish,platform.getName(),null | 
|---|
|  |  |  | ); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //广播 led通知 | 
|---|
|  |  |  | platformJob.setPlatformName(platform.getName()); | 
|---|
|  |  |  | this.broadcastAndLEed(platformJob,Constants.PlatformLedContent.DONE.getInfo(), | 
|---|
|  |  |  | 
|---|
|  |  |  | //获取月台下的所有作业数据 | 
|---|
|  |  |  | List<PlatformJob> platformJobList =  platformJobJoinMapper.selectJoinList(PlatformJob.class,new MPJLambdaWrapper<PlatformJob>() | 
|---|
|  |  |  | .selectAll(PlatformJob.class) | 
|---|
|  |  |  | .select(" ( select pl.CREATE_DATE from platform_log pl where t.id = pl.obj_id and pl.OBJ_TYPE = 5 order by pl.CREATE_DATE desc  limit 1  ) as newStartDate  ") | 
|---|
|  |  |  | .select(" ( select pl.CREATE_DATE from platform_log pl where t.id = pl.obj_id and pl.OBJ_TYPE = 4 order by pl.CREATE_DATE desc  limit 1  ) as newCallDate  ") | 
|---|
|  |  |  | .selectAs(Platform::getName,PlatformJob::getPlatformName) | 
|---|
|  |  |  | .selectAs(Platform::getWorkRate,PlatformJob::getWorkRate) | 
|---|
|  |  |  | .selectAs(PlatformWmsJob::getCarrierName,PlatformJob::getCarrierName) | 
|---|
|  |  |  | .selectAs(PlatformBooks::getId,PlatformJob::getBookId) | 
|---|
|  |  |  | .leftJoin(Platform.class,Platform::getId,PlatformJob::getPlatformId) | 
|---|
|  |  |  | .leftJoin(PlatformWmsJob.class,PlatformWmsJob::getJobId,PlatformJob::getId) | 
|---|
|  |  |  | .eq(PlatformJob::getPlatformId,platformId) | 
|---|
|  |  |  | .leftJoin(PlatformBooks.class,PlatformBooks::getJobId,PlatformJob::getId) | 
|---|
|  |  |  | .eq(PlatformJob::getIsdeleted,Constants.ZERO) | 
|---|
|  |  |  | .in(PlatformJob::getStatus, | 
|---|
|  |  |  | Constants.PlatformJobStatus.WAIT_CALL.getKey(), | 
|---|
|  |  |  | 
|---|
|  |  |  | Constants.PlatformJobStatus.CALLED.getKey(), | 
|---|
|  |  |  | Constants.PlatformJobStatus.WORKING.getKey(), | 
|---|
|  |  |  | Constants.PlatformJobStatus.EXCEPTION.getKey(), | 
|---|
|  |  |  | Constants.PlatformJobStatus.OVER_NUMBER.getKey() | 
|---|
|  |  |  | Constants.PlatformJobStatus.OVER_NUMBER.getKey(), | 
|---|
|  |  |  | Constants.PlatformJobStatus.TRANSFERING.getKey() | 
|---|
|  |  |  | ) | 
|---|
|  |  |  | .like(PlatformJob::getArriveDate, DateUtil.getCurrDate()) | 
|---|
|  |  |  | .orderByDesc(PlatformJob::getId) | 
|---|
|  |  |  | ); | 
|---|
|  |  |  | for (PlatformJob platformJob:platformJobList) { | 
|---|
|  |  |  | 
|---|
|  |  |  | List<PlatformJob> platformJobList =  platformJobJoinMapper.selectJoinList(PlatformJob.class,new MPJLambdaWrapper<PlatformJob>() | 
|---|
|  |  |  | .selectAll(PlatformJob.class) | 
|---|
|  |  |  | .selectAs(Platform::getName,PlatformJob::getPlatformName) | 
|---|
|  |  |  | .select(" ( now() > DATE_ADD( ( select pl.CREATE_DATE from platform_log pl where t.id = pl.obj_id and pl.OBJ_TYPE = 4 order by pl.CREATE_DATE desc  limit 1  )  ,INTERVAL t2.WAIT_CALL_TIME MINUTE) ) as isTimeOut   ") | 
|---|
|  |  |  | .select(" ( now() >= DATE_ADD( ( select pl.CREATE_DATE from platform_log pl where t.id = pl.obj_id and pl.OBJ_TYPE = 4 " + | 
|---|
|  |  |  | "order by pl.CREATE_DATE desc  limit 1  )  ,INTERVAL t2.WAIT_CALL_TIME MINUTE) ) as isTimeOut   ") | 
|---|
|  |  |  | .leftJoin(Platform.class,Platform::getId,PlatformJob::getPlatformId) | 
|---|
|  |  |  | .leftJoin(PlatformGroup.class,PlatformGroup::getId,Platform::getGroupId) | 
|---|
|  |  |  | .eq(PlatformJob::getStatus,Constants.PlatformJobStatus.CALLED.getKey()) | 
|---|
|  |  |  | 
|---|
|  |  |  | ); | 
|---|
|  |  |  | //如果超时 处理数据 并发送led与广播 | 
|---|
|  |  |  | for (PlatformJob platformJob:platformJobList) { | 
|---|
|  |  |  | JobOperateDTO jobOperateDTO = new JobOperateDTO(); | 
|---|
|  |  |  | jobOperateDTO.setJobId(platformJob.getId()); | 
|---|
|  |  |  | this.platformOverNumber(jobOperateDTO); | 
|---|
|  |  |  | this.cancelInPark(platformJob); | 
|---|
|  |  |  | if(Constants.equalsInteger(platformJob.getIsTimeOut(),Constants.ONE)){ | 
|---|
|  |  |  | JobOperateDTO jobOperateDTO = new JobOperateDTO(); | 
|---|
|  |  |  | jobOperateDTO.setJobId(platformJob.getId()); | 
|---|
|  |  |  | this.platformOverNumber(jobOperateDTO); | 
|---|
|  |  |  | this.cancelInPark(platformJob); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|