|  |  |  | 
|---|
|  |  |  | package com.zy.asrs.service.impl; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import com.alibaba.fastjson.JSON; | 
|---|
|  |  |  | import com.alibaba.fastjson.JSONArray; | 
|---|
|  |  |  | import com.alibaba.fastjson.JSONObject; | 
|---|
|  |  |  | import com.baomidou.mybatisplus.mapper.EntityWrapper; | 
|---|
|  |  |  | import com.baomidou.mybatisplus.mapper.Wrapper; | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import java.util.*; | 
|---|
|  |  |  | import java.util.stream.Collectors; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import static com.zy.asrs.utils.Utils.isJson; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 立体仓库WCS系统主流程业务 | 
|---|
|  |  |  | 
|---|
|  |  |  | ledCommand.setLocNo(wrkMast.getLocNo()); | 
|---|
|  |  |  | ledCommand.setStaNo(wrkMast.getStaNo()); | 
|---|
|  |  |  | if (wrkMast.getIoType() != 110 && wrkMast.getIoType() != 10 && wrkMast.getIoType() != 107) { | 
|---|
|  |  |  | //for (WrkDetl wrkDetl : wrkDetls) { | 
|---|
|  |  |  | //    LocDetl locDetl = locDetlService.selectOne(new EntityWrapper<LocDetl>().eq("zpallet", wrkDetl.getZpallet()).eq("matnr", wrkDetl.getMatnr())); | 
|---|
|  |  |  | // | 
|---|
|  |  |  | //    locDetls.forEach(locDetl1 -> { | 
|---|
|  |  |  | //        //工作档中存在该物料则跳过 | 
|---|
|  |  |  | //        String suppCode = ""; | 
|---|
|  |  |  | // | 
|---|
|  |  |  | //        if (wrkDetl.getMatnr().equals(locDetl1.getMatnr())) { | 
|---|
|  |  |  | //            Double anfme = 0D; | 
|---|
|  |  |  | //            if (locDetl != null) { | 
|---|
|  |  |  | //                anfme = locDetl.getAnfme(); | 
|---|
|  |  |  | //            } | 
|---|
|  |  |  | //            if (wrkDetl.getSuppCode() != null) { | 
|---|
|  |  |  | //                suppCode = wrkDetl.getSuppCode(); | 
|---|
|  |  |  | //            } | 
|---|
|  |  |  | //            ledCommand.getMatDtos() | 
|---|
|  |  |  | //                    .add(new MatDto(wrkDetl.getMatnr() | 
|---|
|  |  |  | //                            , wrkDetl.getMaktx() | 
|---|
|  |  |  | //                            , wrkDetl.getAnfme() | 
|---|
|  |  |  | //                            , (wrkDetl.getAnfme()-anfme) | 
|---|
|  |  |  | //                            , wrkDetl.getSpecs() | 
|---|
|  |  |  | //                            , suppCode)); | 
|---|
|  |  |  | //        } else { | 
|---|
|  |  |  | //            if (locDetl1.getSuppCode() != null) { | 
|---|
|  |  |  | //                suppCode = locDetl1.getSuppCode(); | 
|---|
|  |  |  | //            } | 
|---|
|  |  |  | //            ledCommand.getMatDtos() | 
|---|
|  |  |  | //                    .add(new MatDto(locDetl1.getMatnr() | 
|---|
|  |  |  | //                            , locDetl1.getMaktx() | 
|---|
|  |  |  | //                            , 0D | 
|---|
|  |  |  | //                            , locDetl1.getAnfme() | 
|---|
|  |  |  | //                            , locDetl1.getSpecs() | 
|---|
|  |  |  | //                            , suppCode)); | 
|---|
|  |  |  | //        } | 
|---|
|  |  |  | //    }); | 
|---|
|  |  |  | //    //LocDetl locDetl = locDetlService.selectOne(new EntityWrapper<LocDetl>().eq("zpallet", wrkDetl.getZpallet()).eq("matnr", wrkDetl.getMatnr())); | 
|---|
|  |  |  | //} | 
|---|
|  |  |  | List<LocDetl> locDetls = locDetlService.selectList(new EntityWrapper<LocDetl>().eq("loc_no", wrkMast.getSourceLocNo())); | 
|---|
|  |  |  | locDetls.forEach(locDetl -> { | 
|---|
|  |  |  | Wrapper<WrkDetl> wrapper = new EntityWrapper<WrkDetl>().eq("matnr", locDetl.getMatnr()).eq("wrk_no", wrkMast.getWrkNo()); | 
|---|
|  |  |  | 
|---|
|  |  |  | Utils.wapperSetCondition(wrapper, "dead_time", locDetl.getDeadTime()); | 
|---|
|  |  |  | Utils.wapperSetCondition(wrapper, "supp_code", locDetl.getSuppCode());//料箱码 | 
|---|
|  |  |  | WrkDetl detl = wrkDetlService.selectOne(wrapper); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if (Cools.isEmpty(detl)) { | 
|---|
|  |  |  | String suppCode = ""; | 
|---|
|  |  |  | if (locDetl.getSuppCode() != null) { | 
|---|
|  |  |  | 
|---|
|  |  |  | ledCommand.getMatDtos().add(new MatDto(locDetl.getMatnr(), locDetl.getMaktx(), 0D, locDetl.getAnfme(), locDetl.getSpecs(), suppCode)); | 
|---|
|  |  |  | } else { | 
|---|
|  |  |  | String suppCode = ""; | 
|---|
|  |  |  | String orderNo = detl.getOrderNo(); | 
|---|
|  |  |  | if (detl.getSuppCode() != null) { | 
|---|
|  |  |  | suppCode = detl.getSuppCode(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | ledCommand.getMatDtos().add(new MatDto(detl.getMatnr(), detl.getMaktx(), detl.getAnfme(), (locDetl.getAnfme() - detl.getAnfme()), detl.getSpecs(), suppCode)); | 
|---|
|  |  |  | if (isJson(orderNo)) { | 
|---|
|  |  |  | JSONArray orders = JSON.parseArray(orderNo); | 
|---|
|  |  |  | for (Object order : orders) { | 
|---|
|  |  |  | JSONObject order1 = (JSONObject) order; | 
|---|
|  |  |  | ledCommand.getMatDtos().add(new MatDto(detl.getMatnr(), detl.getMaktx(), (Double) order1.get("anfme"), (locDetl.getAnfme() - detl.getAnfme()), detl.getSpecs(), suppCode,(String) order1.get("orderNo"))); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } else { | 
|---|
|  |  |  | ledCommand.getMatDtos().add(new MatDto(detl.getMatnr(), detl.getMaktx(), detl.getAnfme(), (locDetl.getAnfme() - detl.getAnfme()), detl.getSpecs(), suppCode,detl.getOrderNo())); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  | }); | 
|---|
|  |  |  | } | 
|---|