|  |  | 
 |  |  | 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; | 
 |  |  | 
 |  |  |     @Autowired | 
 |  |  |     private MemberMapper memberMapper; | 
 |  |  |     @Autowired | 
 |  |  |     private SystemUserMapper systemUserMapper; | 
 |  |  |     @Autowired | 
 |  |  |     private PlatformJobMapper platformJobMapper; | 
 |  |  |     @Autowired | 
 |  |  |     private PlatformWmsDetailMapper platformWmsDetailMapper; | 
 |  |  | 
 |  |  |     private RetentionMapper retentionMapper; | 
 |  |  |     @Autowired | 
 |  |  |     private WxNoticeConfigMapper wxNoticeConfigMapper; | 
 |  |  |     @Autowired | 
 |  |  |     private PlatformLogMapper platformLogMapper; | 
 |  |  |     /** | 
 |  |  |      * 入库通知任务业务处理 | 
 |  |  |      * @param job 参数 | 
 |  |  | 
 |  |  |      * @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); | 
 |  |  | 
 |  |  |                 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()){ | 
 |  |  | 
 |  |  |                     platformWmsJobMapper.insert(job); | 
 |  |  |                     jobList.add(model); | 
 |  |  |                 } | 
 |  |  |                 jobIdList.add(job.getJobId()); | 
 |  |  |                 if(param.getDetails()!=null && param.getDetails().size()>0){ | 
 |  |  |                     for(WmsInboundDetailRequest d :param.getDetails()){ | 
 |  |  |                         PlatformWmsDetail entity = new PlatformWmsDetail(); | 
 |  |  | 
 |  |  |             if(details.size()>0){ | 
 |  |  |                 platformWmsDetailMapper.insert(details); | 
 |  |  |             } | 
 |  |  |             list.setJobIdList(jobIdList); | 
 |  |  |             if(jobList.size()>0){ | 
 |  |  |                 startEndNoticeToDriver(jobList); | 
 |  |  |             } | 
 |  |  | 
 |  |  |  | 
 |  |  |     private void startEndNoticeToDriver(List<PlatformJob> jobList) { | 
 |  |  |         for(PlatformJob job : jobList){ | 
 |  |  |             //-----TODO-----------任康,发送司机公众号和 | 
 |  |  |             //短信通知 | 
 |  |  |             if(Constants.equalsInteger(job.getStatus(),Constants.PlatformJobStatus.WAIT_CONFIRM.getKey())){ | 
 |  |  |                 SmsEmailServiceImpl.sendPlatformJobSms(systemDictDataBiz, | 
 |  |  | 
 |  |  |                 ); | 
 |  |  |                 //查询司机信息 发送公众号通知 | 
 |  |  |                 if(Objects.nonNull(job.getDriverId())){ | 
 |  |  |                     Member member = memberMapper.selectOne(new QueryWrapper<Member>().lambda().eq(Member::getPhone,job.getDriverId())); | 
 |  |  |                     if(Objects.nonNull(member) && StringUtils.isNotBlank(member.getOpenid())){ | 
 |  |  |                     //发送公众号通知 给提交人 | 
 |  |  |                     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( | 
 |  |  |                         wxPlatNotice.sendWmsTemplateNotice(systemDictDataBiz, | 
 |  |  |                                 wxNoticeConfigMapper,job, | 
 |  |  |                                 WxPlatConstants.platformJobContent.platformJobNewJob, | 
 |  |  |                                 systemDictDataBiz.queryByCode(Constants.WX_PLATFORM,Constants.WX_PLATFORM_ACCESS_TOKEN).getCode(), | 
 |  |  |                                 Arrays.asList(member.getOpenid().split(",")) | 
 |  |  |                                 Arrays.asList(driver.getOpenid().split(",")) | 
 |  |  |                         ); | 
 |  |  |                     } | 
 |  |  |                 } | 
 |  |  |             } | 
 |  |  |  | 
 |  |  |  | 
 |  |  |         } | 
 |  |  |     } | 
 |  |  |  | 
 |  |  | 
 |  |  |     private void dealCarPlatformAndDriverInfo(PlatformJob job,int type) { | 
 |  |  |         //查询车辆是否自有车,以及jobNum表示但求作业数量(非已离园的作业数) | 
 |  |  |         Cars car = carsMapper.selectOne(new QueryWrapper<Cars>() | 
 |  |  |                 .select("*,(select count(1) from platform_job b where b.plate_num='"+job.getCarCodeFront()+"' and b.status in("+ | 
 |  |  |                         Constants.PlatformJobStatus.LEAVED.getKey()+")) as jobNum") | 
 |  |  |                 .select("*,(select count(1) from platform_job b where b.plate_num='"+job.getCarCodeFront()+"' " + | 
 |  |  |                         "and b.status in("+ | 
 |  |  |                         Constants.PlatformJobStatus.WART_SIGN_IN.getKey()+","+ | 
 |  |  |                         Constants.PlatformJobStatus.WART_SIGN_IN.getKey()+","+ | 
 |  |  |                         Constants.PlatformJobStatus.WAIT_CALL.getKey()+","+ | 
 |  |  |                         Constants.PlatformJobStatus.IN_WAIT.getKey()+","+ | 
 |  |  |                         Constants.PlatformJobStatus.CALLED.getKey()+","+ | 
 |  |  |                         Constants.PlatformJobStatus.TRANSFERING.getKey()+","+ | 
 |  |  |                         Constants.PlatformJobStatus.EXCEPTION.getKey()+","+ | 
 |  |  |                         Constants.PlatformJobStatus.WORKING.getKey()+")) as jobNum") | 
 |  |  |                 .lambda() | 
 |  |  |                 .eq(Cars::getIsdeleted,Constants.ZERO) | 
 |  |  |                 .eq(Cars::getType,Constants.ONE) | 
 |  |  | 
 |  |  |             //如果是自有物流车 | 
 |  |  |             job.setType(type==0?Constants.platformJobType.zycxh:Constants.platformJobType.zyczh);//自有车卸货/装货 | 
 |  |  |             job.setCarCodeBack(job.getCarCodeFront());//自有车默认前后车牌一样 | 
 |  |  |             if(retentionMapper.selectCount(new QueryWrapper<Retention>().lambda().eq(Retention::getType,Constants.THREE) | 
 |  |  |                     .eq(Retention::getCarNo,car.getCode()))>Constants.ZERO && car.getJobNum() == 0){ | 
 |  |  |             if(job.getType() ==Constants.platformJobType.zyczh | 
 |  |  |                     && 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.setCompanyNamePath(driver.getCompanyNamePath()); | 
 |  |  |         } | 
 |  |  |         platformJobMapper.insert(job); | 
 |  |  |         if(car !=null){ | 
 |  |  |             //存储操作日志 | 
 |  |  |             PlatformLog platformLog = new PlatformLog(); | 
 |  |  |             platformLog.setIsdeleted(Constants.ZERO); | 
 |  |  |             platformLog.setCreateDate(new Date()); | 
 |  |  |             platformLog.setJobId(job.getId()); | 
 |  |  |             platformLog.setObjType(Constants.PlatformJobLogType.SIGN.getKey()); | 
 |  |  |             platformLog.setContent("自动签到"); | 
 |  |  |             platformLog.setParam4(job.getCarCodeFront()); | 
 |  |  |             platformLog.setAfterContent(JSONObject.toJSONString(job)); | 
 |  |  |             platformLog.setObjId(job.getId().toString()); | 
 |  |  |             platformLog.setParam3("0"); | 
 |  |  |             platformLogMapper.insert(platformLog); | 
 |  |  |         } | 
 |  |  |  | 
 |  |  |  | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     private PlatformJob dealJobBizOutbound(WmsOutboundNoticeRequest param) { | 
 |  |  | 
 |  |  |                     job.setContractNum(param.getContractNum()); | 
 |  |  |                     job.setDriverPhone(param.getDriverPhone()); | 
 |  |  |                     job.setDriverName(param.getDriverName()); | 
 |  |  | //                    job.setOrigin(Constants.ONE); | 
 |  |  |                     platformWmsJobMapper.insert(job); | 
 |  |  |                 } | 
 |  |  |                 jobIdList.add(job.getId()); | 
 |  |  |                 jobIdList.add(job.getJobId()); | 
 |  |  |                 if(param.getDetails()!=null && param.getDetails().size()>0){ | 
 |  |  |                     for(WmsOutboundDetailRequest d :param.getDetails()){ | 
 |  |  |                         PlatformWmsDetail entity = new PlatformWmsDetail(); | 
 |  |  | 
 |  |  |                         entity.setIocode(d.getIoCode()); | 
 |  |  |                         entity.setJobId(job.getJobId()); | 
 |  |  |                         entity.setWmsJobId(job.getId()); | 
 |  |  |                         entity.setContractNum(param.getContractNum()); | 
 |  |  |                         entity.setIoQty(d.getIoQty()); | 
 |  |  |                         entity.setRepertotyAddress(job.getRepertotyAddress()); | 
 |  |  |                         entity.setWmsJobId(job.getId()); | 
 |  |  | 
 |  |  |             if(details.size()>0){ | 
 |  |  |                 platformWmsDetailMapper.insert(details); | 
 |  |  |             } | 
 |  |  |             list.setJobIdList(jobIdList); | 
 |  |  |             if(jobList.size()>0){ | 
 |  |  |                 list.setJobIdList(jobIdList); | 
 |  |  |                 startEndNoticeToDriver(jobList); | 
 |  |  |             } | 
 |  |  |         }catch (Exception e){ | 
 |  |  | 
 |  |  |                         //公众号通知司机 任务取消 | 
 |  |  |                         PlatformJob job = platformJobMapper.selectById(jobId); | 
 |  |  |                         if(Objects.nonNull(job)){ | 
 |  |  |                              Member member = memberMapper.selectById(job.getDriverId()); | 
 |  |  |                             if(Objects.nonNull(member) && StringUtils.isNotBlank(member.getOpenid())){ | 
 |  |  |  | 
 |  |  |                             //发送公众号通知 给提交人 | 
 |  |  |                             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( | 
 |  |  |                                 wxPlatNotice.sendWmsCancelTemplateNotice(systemDictDataBiz, | 
 |  |  |                                         wxNoticeConfigMapper,job, | 
 |  |  |                                         WxPlatConstants.platformJobContent.platformJobCancel, | 
 |  |  |                                         systemDictDataBiz.queryByCode(Constants.WX_PLATFORM,Constants.WX_PLATFORM_ACCESS_TOKEN).getCode(), | 
 |  |  |                                         Arrays.asList(member.getOpenid().split(",")) | 
 |  |  |                                         Arrays.asList(driver.getOpenid().split(",")) | 
 |  |  |                                 ); | 
 |  |  |                             } | 
 |  |  |                         } | 
 |  |  | 
 |  |  |  | 
 |  |  |                         //公众号通知司机 任务取消 | 
 |  |  |                         PlatformJob job = platformJobMapper.selectById(jobId); | 
 |  |  |                         if(Objects.nonNull(job)){ | 
 |  |  |                              Member member = memberMapper.selectById(job.getDriverId()); | 
 |  |  |                             if(Objects.nonNull(member) && StringUtils.isNotBlank(member.getOpenid())){ | 
 |  |  |                         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( | 
 |  |  |                                 wxPlatNotice.sendWmsCancelTemplateNotice(systemDictDataBiz, | 
 |  |  |                                         wxNoticeConfigMapper,job, | 
 |  |  |                                         WxPlatConstants.platformJobContent.platformJobCancel, | 
 |  |  |                                         systemDictDataBiz.queryByCode(Constants.WX_PLATFORM,Constants.WX_PLATFORM_ACCESS_TOKEN).getCode(), | 
 |  |  |                                         Arrays.asList(member.getOpenid().split(",")) | 
 |  |  |                                         Arrays.asList(driver.getOpenid().split(",")) | 
 |  |  |                                 ); | 
 |  |  |                             } | 
 |  |  |                         } | 
 |  |  | 
 |  |  |                     .eq(PlatformWmsDetail::getIsdeleted, Constants.ZERO)); | 
 |  |  |             if(details!=null && details.size()>0){ | 
 |  |  |                 for(PlatformWmsDetail d :details){ | 
 |  |  |                    num.add(Constants.formatBigdecimal(d.getIoQty())); | 
 |  |  |                     num =  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)); | 
 |  |  |             } | 
 |  |  |  | 
 |  |  |             platformJobMapper.update(null,new UpdateWrapper<PlatformJob>().lambda() | 
 |  |  |                     .set(PlatformJob::getTotalNum,num) | 
 |  |  |                     .eq(PlatformJob::getOrigin, Constants.ONE) | 
 |  |  |                     .eq(PlatformJob::getId, jobId)); | 
 |  |  |         } | 
 |  |  |     } | 
 |  |  |     /** |