jiangping
2024-09-14 ccc10c31c93733544212e88bc880744a0595f0d7
server/visits/dmvisit_service/src/main/java/com/doumee/service/business/impl/wms/WmsServiceImpl.java
@@ -192,75 +192,80 @@
    @Override
    @Transactional
    public WmsBaseResponse<WmsBaseDataResponse> inboundNotice(WmsBaseRequest<WmsInboundNoticeRequest> list) {
        if(list ==null || list.getData()==null|| list.getData().size() ==0){
            return returnFailReuslt("请求参数不正确,参数不能为空");
        }
        List<PlatformJob> jobList = new ArrayList<>();
        List<PlatformWmsDetail> details = new ArrayList<>();
        List<String> iocodeList = new ArrayList<>();
        for(WmsInboundNoticeRequest param : list.getData()){
            if(StringUtils.isBlank(param.getIoCode()) ||
                    StringUtils.isBlank(param.getCarrierBillCode())||
                    StringUtils.isBlank(param.getPlateNumber())||
                    StringUtils.isBlank(param.getDriverPhone())){
                return returnFailReuslt("请求参数不正确,参数不合法!");
        try{
            if(list ==null || list.getData()==null|| list.getData().size() ==0){
                return returnFailReuslt("请求参数不正确,参数不能为空");
            }
            //根据承运单号查询任务信息
            PlatformWmsJob job = platformWmsJobMapper.selectOne(new QueryWrapper<PlatformWmsJob>().lambda()
                    .eq(PlatformWmsJob::getCarryBillCode,param.getCarrierBillCode())
                    .eq(PlatformWmsJob::getIsdeleted, Constants.ZERO)
                    .last("limit 1" ));
            if(job == null){
                PlatformJob model =dealJobBizInbound(param);
                job = new PlatformWmsJob();
                job.setCreateDate(new Date());
                job.setIsdeleted(Constants.ZERO);
                job.setIsNew(Constants.ONE);
                job.setCarryBillCode(param.getCarrierBillCode());
                job.setIocode(param.getIoCode());
                job.setCarrierName(param.getCarrierName());
                job.setPlateNumber(param.getPlateNumber());
                job.setType(Constants.ONE);
                job.setIoCreatedate(param.getCreateDate());
                job.setJobId(model.getId());
                job.setDriverPhone(param.getDriverPhone());
                platformWmsJobMapper.insert(job);
                jobList.add(model);
            }
            if(param.getDetails()!=null && param.getDetails().size()>0){
                for(WmsInboundDetailRequest d :param.getDetails()){
                    PlatformWmsDetail entity = new PlatformWmsDetail();
                    entity.setCreateDate(new Date());
                    entity.setIsdeleted(Constants.ZERO);
                    entity.setIocode(d.getIoCode());
                    entity.setJobId(job.getJobId());
                    entity.setWmsJobId(job.getId());
                    entity.setIoQty(d.getIoQty());
                    entity.setStatus(Constants.ZERO);
                    entity.setRate(d.getRate());
                    entity.setMaterialName(d.getMaterialName());
                    entity.setInRepertotyCode(d.getInRepertotyCode());
                    iocodeList.add(d.getIoCode());
                    details.add(entity);
            List<PlatformJob> jobList = new ArrayList<>();
            List<PlatformWmsDetail> details = new ArrayList<>();
            List<String> iocodeList = new ArrayList<>();
            for(WmsInboundNoticeRequest param : list.getData()){
                if(StringUtils.isBlank(param.getIoCode()) ||
                        StringUtils.isBlank(param.getCarrierBillCode())||
                        StringUtils.isBlank(param.getPlateNumber())||
                        StringUtils.isBlank(param.getDriverPhone())){
                    return returnFailReuslt("请求参数不正确,参数不合法!");
                }
                if(job.getIsNew() == 1&& iocodeList.size()>0){
                    //先清理同一个承运单号下重复推送的iocode数据,以最后一次推送为主
                    platformWmsDetailMapper.update(null,new UpdateWrapper<PlatformWmsDetail>().lambda()
                            .set(PlatformWmsDetail::getIsdeleted,Constants.ONE)
                            .eq(PlatformWmsDetail::getIsdeleted,Constants.ZERO)
                            .eq(PlatformWmsDetail::getJobId,job.getJobId())
                            .in(PlatformWmsDetail::getIocode,iocodeList)
                    );
                //根据承运单号查询任务信息
                PlatformWmsJob job = platformWmsJobMapper.selectOne(new QueryWrapper<PlatformWmsJob>().lambda()
                        .eq(PlatformWmsJob::getCarryBillCode,param.getCarrierBillCode())
                        .eq(PlatformWmsJob::getIsdeleted, Constants.ZERO)
                        .last("limit 1" ));
                if(job == null){
                    PlatformJob model =dealJobBizInbound(param);
                    job = new PlatformWmsJob();
                    job.setCreateDate(new Date());
                    job.setIsdeleted(Constants.ZERO);
                    job.setIsNew(Constants.ONE);
                    job.setCarryBillCode(param.getCarrierBillCode());
                    job.setIocode(param.getIoCode());
                    job.setCarrierName(param.getCarrierName());
                    job.setPlateNumber(param.getPlateNumber());
                    job.setType(Constants.ONE);
                    job.setIoCreatedate(param.getCreateDate());
                    job.setJobId(model.getId());
                    job.setDriverPhone(param.getDriverPhone());
                    platformWmsJobMapper.insert(job);
                    jobList.add(model);
                }
                if(param.getDetails()!=null && param.getDetails().size()>0){
                    for(WmsInboundDetailRequest d :param.getDetails()){
                        PlatformWmsDetail entity = new PlatformWmsDetail();
                        entity.setCreateDate(new Date());
                        entity.setIsdeleted(Constants.ZERO);
                        entity.setIocode(d.getIoCode());
                        entity.setJobId(job.getJobId());
                        entity.setWmsJobId(job.getId());
                        entity.setIoQty(d.getIoQty());
                        entity.setStatus(Constants.ZERO);
                        entity.setRate(d.getRate());
                        entity.setMaterialName(d.getMaterialName());
                        entity.setInRepertotyCode(d.getInRepertotyCode());
                        iocodeList.add(d.getIoCode());
                        details.add(entity);
                    }
                    if(job.getIsNew() != 1&& iocodeList.size()>0){
                        //先清理同一个承运单号下重复推送的iocode数据,以最后一次推送为主
                        platformWmsDetailMapper.update(null,new UpdateWrapper<PlatformWmsDetail>().lambda()
                                .set(PlatformWmsDetail::getIsdeleted,Constants.ONE)
                                .eq(PlatformWmsDetail::getIsdeleted,Constants.ZERO)
                                .eq(PlatformWmsDetail::getWmsJobId,job.getId())
                                .in(PlatformWmsDetail::getIocode,iocodeList)
                        );
                    }
                }
            }
        }
        if(details.size()>0){
            platformWmsDetailMapper.insert(details);
        }
        if(jobList.size()>0){
            startEndNoticeToDriver(jobList);
            if(details.size()>0){
                platformWmsDetailMapper.insert(details);
            }
            if(jobList.size()>0){
                startEndNoticeToDriver(jobList);
            }
        }catch (Exception e){
            log.error("【WMS】处理入库取消通知业务===============业务处理异常"+e.getMessage());
            return returnFailReuslt("业务处理异常");
        }
        return returnSuccessReuslt(null);
    }
@@ -331,8 +336,6 @@
        platformJobMapper.insert(job);
        return job;
    }
    /**
     * 出库通知任务业务处理
     * @param list 参数
@@ -340,73 +343,80 @@
     */
    @Override
    public WmsBaseResponse outboundNotice(WmsBaseRequest<WmsOutboundNoticeRequest> list) {
        if(list ==null ||list.getData()==null ||  list.getData().size() ==0){
            return returnFailReuslt("请求参数不正确,参数不能为空");
        }
        List<PlatformJob> jobList = new ArrayList<>();
        List<PlatformWmsDetail> details = new ArrayList<>();
        List<String> iocodeList = new ArrayList<>();
        for(WmsOutboundNoticeRequest param : list.getData()){
            if(StringUtils.isBlank(param.getIoCode()) ||
                    StringUtils.isBlank(param.getCarrierBillCode())||
                    StringUtils.isBlank(param.getPlateNumber())||
                    StringUtils.isBlank(param.getDriverPhone())){
                return returnFailReuslt("请求参数不正确,参数不合法!");
            }
            //根据承运单号查询任务信息
            PlatformWmsJob job = platformWmsJobMapper.selectOne(new QueryWrapper<PlatformWmsJob>().lambda()
                    .eq(PlatformWmsJob::getCarryBillCode,param.getCarrierBillCode())
                    .eq(PlatformWmsJob::getIsdeleted, Constants.ZERO)
                    .last("limit 1" ));
            if(job == null){
                PlatformJob model =dealJobBizOutbound(param);
                job = new PlatformWmsJob();
                job.setCreateDate(new Date());
                job.setIsdeleted(Constants.ZERO);
                job.setIsNew(Constants.ONE);
                job.setCarryBillCode(param.getCarrierBillCode());
                job.setIocode(param.getIoCode());
                job.setCarrierName(param.getCarrierName());
                job.setPlateNumber(param.getPlateNumber());
                job.setType(Constants.ONE);
                job.setIoCreatedate(param.getCreateDate());
                job.setJobId(job.getId());
                job.setDriverPhone(param.getDriverPhone());
                platformWmsJobMapper.insert(job);
                jobList.add(model);
        try{
            if(list ==null ||list.getData()==null ||  list.getData().size() ==0){
                return returnFailReuslt("请求参数不正确,参数不能为空");
            }
            if(param.getDetails()!=null && param.getDetails().size()>0){
                for(WmsOutboundDetailRequest d :param.getDetails()){
                    PlatformWmsDetail entity = new PlatformWmsDetail();
                    entity.setCreateDate(new Date());
                    entity.setIsdeleted(Constants.ZERO);
                    entity.setIocode(d.getIoCode());
                    entity.setJobId(job.getJobId());
                    entity.setWmsJobId(job.getId());
                    entity.setIoQty(d.getIoQty());
                    entity.setStatus(Constants.ZERO);
                    entity.setRate(d.getRate());
                    entity.setMaterialName(d.getMaterialName());
                    iocodeList.add(d.getIoCode());
                    details.add(entity);
            List<PlatformJob> jobList = new ArrayList<>();
            List<PlatformWmsDetail> details = new ArrayList<>();
            List<String> iocodeList = new ArrayList<>();
            for(WmsOutboundNoticeRequest param : list.getData()){
                if(StringUtils.isBlank(param.getIoCode()) ||
                        StringUtils.isBlank(param.getCarrierBillCode())||
                        StringUtils.isBlank(param.getPlateNumber())||
                        StringUtils.isBlank(param.getDriverPhone())){
                    return returnFailReuslt("请求参数不正确,参数不合法!");
                }
                if(job.getIsNew() == 1&& iocodeList.size()>0){
                    //先清理同一个承运单号下重复推送的iocode数据,以最后一次推送为主
                    platformWmsDetailMapper.update(null,new UpdateWrapper<PlatformWmsDetail>().lambda()
                            .set(PlatformWmsDetail::getIsdeleted,Constants.ONE)
                            .eq(PlatformWmsDetail::getIsdeleted,Constants.ZERO)
                            .eq(PlatformWmsDetail::getJobId,job.getJobId())
                            .in(PlatformWmsDetail::getIocode,iocodeList)
                    );
                //根据承运单号查询任务信息
                PlatformWmsJob job = platformWmsJobMapper.selectOne(new QueryWrapper<PlatformWmsJob>().lambda()
                        .eq(PlatformWmsJob::getCarryBillCode,param.getCarrierBillCode())
                        .eq(PlatformWmsJob::getIsdeleted, Constants.ZERO)
                        .last("limit 1" ));
                if(job == null){
                    PlatformJob model =dealJobBizOutbound(param);
                    job = new PlatformWmsJob();
                    job.setCreateDate(new Date());
                    job.setIsdeleted(Constants.ZERO);
                    job.setIsNew(Constants.ONE);
                    job.setCarryBillCode(param.getCarrierBillCode());
                    job.setIocode(param.getIoCode());
                    job.setCarrierName(param.getCarrierName());
                    job.setPlateNumber(param.getPlateNumber());
                    job.setType(Constants.ONE);
                    job.setIoCreatedate(param.getCreateDate());
                    job.setJobId(job.getId());
                    job.setDriverPhone(param.getDriverPhone());
                    platformWmsJobMapper.insert(job);
                    jobList.add(model);
                }
                if(param.getDetails()!=null && param.getDetails().size()>0){
                    for(WmsOutboundDetailRequest d :param.getDetails()){
                        PlatformWmsDetail entity = new PlatformWmsDetail();
                        entity.setCreateDate(new Date());
                        entity.setIsdeleted(Constants.ZERO);
                        entity.setIocode(d.getIoCode());
                        entity.setJobId(job.getJobId());
                        entity.setWmsJobId(job.getId());
                        entity.setIoQty(d.getIoQty());
                        entity.setWmsJobId(job.getId());
                        entity.setStatus(Constants.ZERO);
                        entity.setRate(d.getRate());
                        entity.setMaterialName(d.getMaterialName());
                        iocodeList.add(d.getIoCode());
                        details.add(entity);
                    }
                    if(job.getIsNew() != 1 && iocodeList.size()>0){
                        //先清理同一个承运单号下重复推送的iocode数据,以最后一次推送为主
                        platformWmsDetailMapper.update(null,new UpdateWrapper<PlatformWmsDetail>().lambda()
                                .set(PlatformWmsDetail::getIsdeleted,Constants.ONE)
                                .eq(PlatformWmsDetail::getIsdeleted,Constants.ZERO)
                                .eq(PlatformWmsDetail::getWmsJobId,job.getId())
                                .in(PlatformWmsDetail::getIocode,iocodeList)
                        );
                    }
                }
            }
        }
        if(details.size()>0){
            platformWmsDetailMapper.insert(details);
        }
        if(jobList.size()>0){
            startEndNoticeToDriver(jobList);
            if(details.size()>0){
                platformWmsDetailMapper.insert(details);
            }
            if(jobList.size()>0){
                startEndNoticeToDriver(jobList);
            }
        }catch (Exception e){
            log.error("【WMS】处理入库取消通知业务===============业务处理异常"+e.getMessage());
            return returnFailReuslt("业务处理异常");
        }
        return returnSuccessReuslt(null);
    }
@@ -417,9 +427,28 @@
     */
    @Override
    public WmsBaseResponse cancelInbound(WmsBaseRequest<WmsActionNoticeRequest> list) {
        //TODO-------------------处理入库取消通知业务--------------------
        if(list ==null||list.getData()==null || list.getData().size() ==0){
            return returnFailReuslt("请求参数不正确,参数不能为空");
        //-----------------处理入库取消通知业务--------------------
        try {
            if(list ==null||list.getData()==null || list.getData().size() ==0 || list.getData().get(0).getIoCode() == null){
                return returnFailReuslt("请求参数不正确,参数不能为空");
            }
            List<String> iocodeList = new ArrayList<>();
            for(WmsActionNoticeRequest param :list.getData()){
                if(StringUtils.isNotBlank(param.getIoCode())){
                    iocodeList.add(param.getIoCode());
                }
            }
            if(iocodeList.size() ==0 ){
                return returnFailReuslt("请求参数iocode不正确,参数不能为空");
            }
            //取消全部数据状态为 【已取消】
            platformWmsDetailMapper.update(null,new UpdateWrapper<PlatformWmsDetail>().lambda()
                    .set(PlatformWmsDetail::getStatus,Constants.TWO)
                    .in(PlatformWmsDetail::getIocode,iocodeList)
                    .eq(PlatformWmsDetail::getIsdeleted, Constants.ZERO));
        }catch (Exception e){
            log.error("【WMS】处理入库取消通知业务===============业务处理异常"+e.getMessage());
            return returnFailReuslt("业务处理异常");
        }
        return returnSuccessReuslt(null);
    }
@@ -430,18 +459,28 @@
     */
    @Override
    public WmsBaseResponse cancelOutbound(WmsBaseRequest<WmsActionNoticeRequest> list) {
        if(list ==null||list.getData()==null || list.getData().size() ==0){
            return returnFailReuslt("请求参数不正确,参数不能为空");
        try {
            if(list ==null||list.getData()==null || list.getData().size() ==0 ){
                return returnFailReuslt("请求参数不正确,参数不能为空");
            }
            List<String> iocodeList = new ArrayList<>();
            for(WmsActionNoticeRequest param :list.getData()){
                if(StringUtils.isNotBlank(param.getIoCode())){
                    iocodeList.add(param.getIoCode());
                }
            }
            if(iocodeList.size() ==0 ){
                return returnFailReuslt("请求参数iocode不正确,参数不能为空");
            }
            //取消全部数据状态为 【已取消】
             platformWmsDetailMapper.update(null,new UpdateWrapper<PlatformWmsDetail>().lambda()
                    .set(PlatformWmsDetail::getStatus,Constants.TWO)
                    .in(PlatformWmsDetail::getIocode,iocodeList)
                    .eq(PlatformWmsDetail::getIsdeleted, Constants.ZERO));
        }catch (Exception e){
            log.error("【WMS】出库取消通知任务业务处理===============业务处理异常"+e.getMessage());
            return returnFailReuslt("业务处理异常");
        }
        List<String> iocodeList = new ArrayList<>();
        for(WmsActionNoticeRequest param :list.getData()){
            iocodeList.add(param.getIoCode());
        }
        //取消全部数据状态为 【已取消】
         platformWmsDetailMapper.update(null,new UpdateWrapper<PlatformWmsDetail>().lambda()
                .set(PlatformWmsDetail::getStatus,Constants.TWO)
                .in(PlatformWmsDetail::getIocode,iocodeList)
                .eq(PlatformWmsDetail::getIsdeleted, Constants.ZERO));
        return returnSuccessReuslt(null);
    }
    /**
@@ -451,19 +490,28 @@
     */
    @Override
    public WmsBaseResponse doneTask(WmsBaseRequest<WmsActionNoticeRequest> list) {
        if(list ==null||list.getData()==null || list.getData().size() ==0){
            return returnFailReuslt("请求参数不正确,参数不能为空");
        try {
            if(list ==null||list.getData()==null || list.getData().size() ==0){
                return returnFailReuslt("请求参数不正确,参数不能为空");
            }
            List<String> iocodeList = new ArrayList<>();
            for(WmsActionNoticeRequest param :list.getData()){
                if(StringUtils.isNotBlank(param.getIoCode())){
                    iocodeList.add(param.getIoCode());
                }
            }
            if(iocodeList.size() ==0 ){
                return returnFailReuslt("请求参数iocode不正确,参数不能为空");
            }
            //取消全部数据状态为 【已完成】
            platformWmsDetailMapper.update(null,new UpdateWrapper<PlatformWmsDetail>().lambda()
                    .set(PlatformWmsDetail::getStatus,Constants.ONE)
                    .in(PlatformWmsDetail::getIocode,iocodeList)
                    .eq(PlatformWmsDetail::getIsdeleted, Constants.ZERO));
        }catch (Exception e){
            log.error("【WMS】作业完成通知任务业务处理===============业务处理异常"+e.getMessage());
            return returnFailReuslt("业务处理异常");
        }
        List<String> iocodeList = new ArrayList<>();
        for(WmsActionNoticeRequest param :list.getData()){
            iocodeList.add(param.getIoCode());
        }
        //取消全部数据状态为 【已完成】
        platformWmsDetailMapper.update(null,new UpdateWrapper<PlatformWmsDetail>().lambda()
                .set(PlatformWmsDetail::getStatus,Constants.ONE)
                .in(PlatformWmsDetail::getIocode,iocodeList)
                .eq(PlatformWmsDetail::getIsdeleted, Constants.ZERO));
        return returnSuccessReuslt(null);
    }
@@ -475,6 +523,7 @@
    private WmsBaseResponse returnFailReuslt(String msg) {
        WmsBaseResponse response = new WmsBaseResponse();
        response.setCode(-1);
        response.setData(new ArrayList<>());
        WmsBaseDataResponse rData = new WmsBaseDataResponse();
        rData.setMsgDescr(msg);
@@ -491,6 +540,7 @@
    private WmsBaseResponse returnSuccessReuslt(String msg) {
        WmsBaseResponse response = new WmsBaseResponse();
        response.setCode(1);
        response.setData(new ArrayList<>());
        WmsBaseDataResponse rData = new WmsBaseDataResponse();
        rData.setMsgDescr(StringUtils.defaultString(msg,"操作成功"));