| | |
| | | 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.core.wx.wxPlat.WxPlatConstants; |
| | | import com.doumee.core.wx.wxPlat.WxPlatNotice; |
| | | import com.doumee.dao.business.*; |
| | | import com.doumee.dao.business.dao.MemberMapper; |
| | | import com.doumee.dao.business.dao.SmsConfigMapper; |
| | | import com.doumee.dao.business.dao.SmsEmailMapper; |
| | | import com.doumee.dao.business.model.*; |
| | | |
| | | import com.doumee.dao.business.model.Member; |
| | | import com.doumee.dao.system.SystemUserMapper; |
| | | import com.doumee.dao.system.model.SystemUser; |
| | | 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.math.BigDecimal; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * WMS平台对接Service实现 |
| | |
| | | @Autowired |
| | | private MemberMapper memberMapper; |
| | | @Autowired |
| | | private SystemUserMapper systemUserMapper; |
| | | @Autowired |
| | | private PlatformJobMapper platformJobMapper; |
| | | @Autowired |
| | | private PlatformWmsDetailMapper platformWmsDetailMapper; |
| | |
| | | private SmsEmailMapper smsEmailMapper; |
| | | @Autowired |
| | | private EmayService emayService; |
| | | @Autowired |
| | | private RetentionMapper retentionMapper; |
| | | @Autowired |
| | | private WxNoticeConfigMapper wxNoticeConfigMapper; |
| | | /** |
| | | * 入库通知任务业务处理 |
| | | * @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】出库作业的分配月台"; |
| | |
| | | * @return |
| | | */ |
| | | @Override |
| | | public WmsBaseResponse<WmsInventoryDataResponse> getInventoryList(){ |
| | | public WmsBaseResponse<WmsBaseDataResponse> getInventoryList(){ |
| | | String url = systemDictDataBiz.queryByCode(Constants.WMS_PARAM,Constants.WMS_GET_INVENTORYLIST_URL).getCode() ; |
| | | String name = "【WMS】库存查询" ; |
| | | WmsBaseResponse<WmsInventoryDataResponse> response = sendHttpRequest(url,name,JSONObject.toJSONString(new JSONObject()),new TypeReference< WmsBaseResponse<WmsInventoryDataResponse>>(){}); |
| | | WmsBaseResponse<WmsBaseDataResponse> response = sendHttpRequest(url,name,JSONObject.toJSONString(new JSONObject()),new TypeReference< WmsBaseResponse<WmsBaseDataResponse>>(){}); |
| | | if(response!=null |
| | | && response.getData() !=null |
| | | && response.getData().size()>0 |
| | |
| | | return result; |
| | | }catch (Exception e){ |
| | | success = 1; |
| | | e.printStackTrace(); |
| | | log.error("【"+name+"】================失败===="+ JSONObject.toJSONString(param)); |
| | | }finally { |
| | | saveInterfaceLog(url,name,param,success,res,Constants.ZERO); |
| | |
| | | } |
| | | private static void logResult(WmsBaseResponse<WmsBaseDataResponse> res,String name) { |
| | | if(StringUtils.equals(res.getData().get(0).getSuccess(), WmsBaseResponse.CODE_SUCCESS)){ |
| | | log.info("【WMS接口:"+name+"】================成功====\n"+res); |
| | | log.info("【WMS接口:"+name+"】================成功====\n"+ JSONObject.toJSONString(res)); |
| | | }else{ |
| | | log.error("【WMS接口:"+name+"】================失败====:\n"+ res); |
| | | log.error("【WMS接口:"+name+"】================失败====:\n"+ JSONObject.toJSONString(res)); |
| | | } |
| | | } |
| | | /** |
| | |
| | | return returnFailReuslt("请求参数不正确,参数不能为空"); |
| | | } |
| | | List<PlatformJob> jobList = new ArrayList<>(); |
| | | List<Integer> jobIdList = new ArrayList<>(); |
| | | List<PlatformWmsDetail> details = new ArrayList<>(); |
| | | List<String> iocodeList = new ArrayList<>(); |
| | | for(WmsInboundNoticeRequest param : list.getData()){ |
| | |
| | | job.setPlateNumber(param.getPlateNumber()); |
| | | job.setType(Constants.ZERO); |
| | | job.setIoCreatedate(param.getCreateDate()); |
| | | // job.setOrigin(Constants.ONE); |
| | | job.setJobId(model.getId()); |
| | | job.setDriverPhone(param.getDriverPhone()); |
| | | platformWmsJobMapper.insert(job); |
| | | jobList.add(model); |
| | | } |
| | | jobIdList.add(job.getId()); |
| | | if(param.getDetails()!=null && param.getDetails().size()>0){ |
| | | for(WmsInboundDetailRequest d :param.getDetails()){ |
| | | PlatformWmsDetail entity = new PlatformWmsDetail(); |
| | |
| | | platformWmsDetailMapper.insert(details); |
| | | } |
| | | if(jobList.size()>0){ |
| | | list.setJobIdList(jobIdList); |
| | | startEndNoticeToDriver(jobList); |
| | | } |
| | | }catch (Exception e){ |
| | |
| | | |
| | | private void startEndNoticeToDriver(List<PlatformJob> jobList) { |
| | | for(PlatformJob job : jobList){ |
| | | //-----TODO-----------任康,发送司机公众号和 |
| | | //短信通知 |
| | | if(Constants.equalsInteger(job.getStatus(),Constants.PlatformJobStatus.WAIT_CONFIRM.getKey())){ |
| | | SmsEmailServiceImpl.sendPlatformJobSms(systemDictDataBiz, |
| | | emayService,smsEmailMapper,smsConfigMapper,platformJobMapper,job.getId(), |
| | | SmsConstants.platformJobContent.platformJobNewJob,null,null |
| | | ); |
| | | //查询司机信息 发送公众号通知 |
| | | if(Objects.nonNull(job.getDriverId())){ |
| | | //发送公众号通知 给提交人 |
| | | SystemUser driver = systemUserMapper.selectOne(new QueryWrapper<SystemUser>().lambda() |
| | | .eq(SystemUser::getDeleted, Constants.ZERO) |
| | | .eq(SystemUser::getType, Constants.ZERO) |
| | | .eq(SystemUser::getMobile,job.getDrivierPhone()) |
| | | .last(" limit 1 ")); |
| | | if(Objects.nonNull(driver) && StringUtils.isNotBlank(driver.getOpenid())){ |
| | | WxPlatNotice wxPlatNotice = new WxPlatNotice(); |
| | | wxPlatNotice.sendWmsTemplateNotice(systemDictDataBiz, |
| | | wxNoticeConfigMapper,job, |
| | | WxPlatConstants.platformJobContent.platformJobNewJob, |
| | | systemDictDataBiz.queryByCode(Constants.WX_PLATFORM,Constants.WX_PLATFORM_ACCESS_TOKEN).getCode(), |
| | | Arrays.asList(driver.getOpenid().split(",")) |
| | | ); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | |
| | | job.setCarCodeFront(param.getPlateNumber()); |
| | | job.setDrivierPhone(param.getDriverPhone()); |
| | | job.setDriverName(param.getDriverName()); |
| | | job.setOrigin(Constants.ONE); |
| | | //处理作业的车辆、司机、月台组关联关系,卸货 |
| | | dealCarPlatformAndDriverInfo(job,0); |
| | | // platformJobMapper.insert(job); |
| | |
| | | //如果是自有物流车 |
| | | 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() |
| | |
| | | job.setCarCodeFront(param.getPlateNumber()); |
| | | job.setDrivierPhone(param.getDriverPhone()); |
| | | job.setDriverName(param.getDriverName()); |
| | | job.setOrigin(Constants.ONE); |
| | | //处理作业的车辆、司机、月台组关联关系,装货 |
| | | dealCarPlatformAndDriverInfo(job,1); |
| | | return job; |
| | |
| | | return returnFailReuslt("请求参数不正确,参数不能为空"); |
| | | } |
| | | List<PlatformJob> jobList = new ArrayList<>(); |
| | | List<Integer> jobIdList = new ArrayList<>(); |
| | | List<PlatformWmsDetail> details = new ArrayList<>(); |
| | | List<String> iocodeList = new ArrayList<>(); |
| | | for(WmsOutboundNoticeRequest param : list.getData()){ |
| | |
| | | job.setContractNum(param.getContractNum()); |
| | | job.setDriverPhone(param.getDriverPhone()); |
| | | job.setDriverName(param.getDriverName()); |
| | | // job.setOrigin(Constants.ONE); |
| | | platformWmsJobMapper.insert(job); |
| | | jobList.add(model); |
| | | } |
| | | jobIdList.add(job.getId()); |
| | | if(param.getDetails()!=null && param.getDetails().size()>0){ |
| | | for(WmsOutboundDetailRequest d :param.getDetails()){ |
| | | PlatformWmsDetail entity = new PlatformWmsDetail(); |
| | |
| | | entity.setJobId(job.getJobId()); |
| | | entity.setWmsJobId(job.getId()); |
| | | entity.setIoQty(d.getIoQty()); |
| | | entity.setRepertotyAddress(job.getRepertotyAddress()); |
| | | entity.setWmsJobId(job.getId()); |
| | | entity.setStatus(Constants.ZERO); |
| | | entity.setRate(d.getRate()); |
| | |
| | | .in(PlatformWmsDetail::getIocode,iocodeList) |
| | | ); |
| | | } |
| | | jobIdList.add(job.getId()); |
| | | } |
| | | } |
| | | if(details.size()>0){ |
| | | platformWmsDetailMapper.insert(details); |
| | | } |
| | | if(jobList.size()>0){ |
| | | list.setJobIdList(jobIdList); |
| | | startEndNoticeToDriver(jobList); |
| | | } |
| | | }catch (Exception e){ |
| | |
| | | .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 |
| | | ); |
| | | //公众号通知司机 任务取消 |
| | | PlatformJob job = platformJobMapper.selectById(jobId); |
| | | if(Objects.nonNull(job)){ |
| | | |
| | | //发送公众号通知 给提交人 |
| | | SystemUser driver = systemUserMapper.selectOne(new QueryWrapper<SystemUser>().lambda() |
| | | .eq(SystemUser::getDeleted, Constants.ZERO) |
| | | .eq(SystemUser::getType, Constants.ZERO) |
| | | .eq(SystemUser::getMobile,job.getDrivierPhone()) |
| | | .last(" limit 1 ")); |
| | | if(Objects.nonNull(driver) && StringUtils.isNotBlank(driver.getOpenid())){ |
| | | WxPlatNotice wxPlatNotice = new WxPlatNotice(); |
| | | wxPlatNotice.sendWmsCancelTemplateNotice(systemDictDataBiz, |
| | | wxNoticeConfigMapper,job, |
| | | WxPlatConstants.platformJobContent.platformJobCancel, |
| | | systemDictDataBiz.queryByCode(Constants.WX_PLATFORM,Constants.WX_PLATFORM_ACCESS_TOKEN).getCode(), |
| | | Arrays.asList(driver.getOpenid().split(",")) |
| | | ); |
| | | } |
| | | } |
| | | |
| | | } |
| | | } |
| | | } |
| | | |
| | | }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 |
| | | ); |
| | | |
| | | //公众号通知司机 任务取消 |
| | | PlatformJob job = platformJobMapper.selectById(jobId); |
| | | if(Objects.nonNull(job)){ //发送公众号通知 给提交人 |
| | | SystemUser driver = systemUserMapper.selectOne(new QueryWrapper<SystemUser>().lambda() |
| | | .eq(SystemUser::getDeleted, Constants.ZERO) |
| | | .eq(SystemUser::getType, Constants.ZERO) |
| | | .eq(SystemUser::getMobile,job.getDrivierPhone()) |
| | | .last(" limit 1 ")); |
| | | if(Objects.nonNull(driver) && StringUtils.isNotBlank(driver.getOpenid())){ |
| | | WxPlatNotice wxPlatNotice = new WxPlatNotice(); |
| | | wxPlatNotice.sendWmsCancelTemplateNotice(systemDictDataBiz, |
| | | wxNoticeConfigMapper,job, |
| | | WxPlatConstants.platformJobContent.platformJobCancel, |
| | | systemDictDataBiz.queryByCode(Constants.WX_PLATFORM,Constants.WX_PLATFORM_ACCESS_TOKEN).getCode(), |
| | | Arrays.asList(driver.getOpenid().split(",")) |
| | | ); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | }catch (Exception e){ |
| | | log.error("【WMS】出库取消通知任务业务处理===============业务处理异常"+e.getMessage()); |
| | | return returnFailReuslt("业务处理异常"); |
| | |
| | | return returnSuccessReuslt(null); |
| | | } |
| | | /** |
| | | * 处理作业行数据的运输总量信息 |
| | | * @param jobList 参数 |
| | | * @return |
| | | */ |
| | | @Override |
| | | public void computjobTotalNum(List<Integer> jobList) { |
| | | if(jobList==null || jobList.size()==0){ |
| | | return; |
| | | } |
| | | for(Integer jobId : jobList){ |
| | | BigDecimal num = new BigDecimal(0); |
| | | List<PlatformWmsDetail> details = platformWmsDetailMapper.selectList( new QueryWrapper<PlatformWmsDetail>().lambda() |
| | | .eq(PlatformWmsDetail::getJobId,jobId) |
| | | .eq(PlatformWmsDetail::getIsdeleted, Constants.ZERO)); |
| | | if(details!=null && details.size()>0){ |
| | | for(PlatformWmsDetail d :details){ |
| | | num.add(Constants.formatBigdecimal(d.getIoQty())); |
| | | } |
| | | platformJobMapper.update(null,new UpdateWrapper<PlatformJob>().lambda() |
| | | .set(PlatformJob::getTotalNum,num) |
| | | .eq(PlatformJob::getOrigin, Constants.ZERO) |
| | | .eq(PlatformJob::getId, jobId)); |
| | | } |
| | | |
| | | } |
| | | } |
| | | /** |
| | | * 作业完成通知任务业务处理 |
| | | * @param list 参数 |
| | | * @return |