| | |
| | | import com.mandi.basicconfig.mapper.NczsjMapper; |
| | | import com.mandi.basicconfig.persist.*; |
| | | import com.mandi.common.JSONobj; |
| | | import com.mandi.common.Jacksonmethod; |
| | | import com.mandi.common.ParamFileter.BigDecimalfiter; |
| | | import com.mandi.common.SpringContext; |
| | | import com.mandi.common.Wxhtmethod; |
| | |
| | | prr.setErrmsg("参数:卡号关联的车牌号和业务单关联的车牌号不一致"); |
| | | return prr; |
| | | } |
| | | |
| | | // yktywdh = fdb.getBsNo(); |
| | | |
| | | int wcnum=this.bsper.getweightDoc(vehicleId, fdb.getBsNo()); |
| | |
| | | } |
| | | // 现场过完毛重后出现扫码装车的,必须重新过磅 |
| | | int grossNum=this.bsper.getgrosstDoc(vehicleId, fdb.getBsNo()); |
| | | |
| | | List tdmxPchList = new ArrayList(); |
| | | for (JsonElement je : dataArr) { |
| | | JsonObject jo=je.getAsJsonObject(); |
| | | String tdmx_pch = jo.get("tdmx_pch").getAsString(); |
| | | tdmxPchList.add(tdmx_pch); |
| | | } |
| | | /*if("08".equals(fdb.getSdepartNo())) { // 只是义瑞厂区有效 |
| | | // 检查是否当前区域已经排队 |
| | | Map paramMap = new HashMap(); |
| | | paramMap.put("vehicleId", vehicleId); |
| | | paramMap.put("tdmxPchList", tdmxPchList); |
| | | String jsonStr = Jacksonmethod.tojson(paramMap, false); |
| | | JsonObject jsonObject = Wxhtmethod.postJsonStr(Contants.yr_canDoScanUrl, jsonStr); |
| | | if (jsonObject.get("code").getAsInt() != 0) { |
| | | prr.setCode(1); |
| | | prr.setErrmsg(jsonObject.get("errmsg").getAsString()); |
| | | return prr; |
| | | } |
| | | }*/ |
| | | for (JsonElement je : dataArr) { |
| | | JsonObject jo=je.getAsJsonObject(); |
| | | String tdmx_pch = jo.get("tdmx_pch").getAsString(); |
| | |
| | | // 此处异步触发一下明晟发车 |
| | | if("06".equals(fdb.getSdepartNo())) { |
| | | final String cph = currPch; |
| | | final String finalVehicleId = vehicleId; |
| | | ThreadPoolUtil.getInstance().execute(()->{ |
| | | synchronized (FdXSTDService.refreshMsLedLock) { |
| | | if (FdXSTDService.refreshMsLedLock) { // 系统繁忙 |
| | | log.info(finalVehicleId + "" + cph + "系统繁忙!"); |
| | | return; |
| | | } |
| | | } |
| | | try { |
| | | synchronized (FdXSTDService.refreshMsLedLock) { |
| | | if (FdXSTDService.refreshMsLedLock) { // 系统繁忙 |
| | | return ; |
| | | } |
| | | FdXSTDService.refreshMsLedLock = true; |
| | | } |
| | | sendToMsLed(cph); |
| | | } catch (Exception e) { |
| | | log.error(e); |
| | | log.error("出现异常:"+ e.getMessage(),e); |
| | | } finally { |
| | | synchronized (FdXSTDService.refreshMsLedLock) { |
| | | FdXSTDService.refreshMsLedLock = false; |
| | |
| | | if("08".equals(fdb.getSdepartNo())) { |
| | | final String cph = currPch; |
| | | ThreadPoolUtil.getInstance().execute(()->{ |
| | | |
| | | Map scanCodeParamMap = new HashMap(); |
| | | scanCodeParamMap.put("pch",cph); |
| | | Wxhtmethod.post(Contants.yr_scanCodeNoticeUrl, scanCodeParamMap); |
| | | |
| | | try { |
| | | synchronized (FdXSTDService.refreshYrLedLock) { |
| | | if (FdXSTDService.refreshYrLedLock) { // 系统繁忙 |
| | |
| | | Map<String,List<Map>> ywbhListMap = new HashMap<>(); |
| | | for (Map map : totalList) { |
| | | String ywdw = (String) map.get("tdmx_fdywbh"); |
| | | if(ywdw == null) { |
| | | log.info("出现业务单号为null的情况:" + Jacksonmethod.tojson(map,false)); |
| | | continue; |
| | | } |
| | | if(ywbhListMap.get(ywdw) == null) { |
| | | ywbhListMap.put(ywdw, new ArrayList<>()); |
| | | } |
| | |
| | | //"(车牌号)\\-(A区已装车)/(A区总计)\\-(B区已装车)/(B区总计)\\-(C区已装车)/(C区总计)\\r\\n"; |
| | | String formatStr = "%s %s/%s %s/%s %s/%s\r\n"; |
| | | // 只有1个区 |
| | | String speakTxtFormatStr1 = "车号%s ,装货%d件已完成,请司机清点货物后尽快驶离装货区。"; |
| | | // 只有2个区 |
| | | String speakTxtFormatStr2 = "车号%s,%s区装货%d件已全部扫描完成,请司机清点货物后去%s区装货。"; |
| | | // 只有3个区 |
| | | String speakTxtFormatStr3 = "车号%s,%s区装货%d件已全部扫描完成,请司机清点货物后去%s区%s区装货。"; |
| | | |
| | | Map speakParam = new HashMap(1); |
| | | for (Map.Entry<String, List<Map>> entry : ywbhListMap.entrySet()) { |
| | | // 遍历每个业务单的 |
| | | // 当前装车A、B、C区 |
| | | boolean currA = false,currB = false, currC = false; |
| | | boolean hasZcwc = false; // 保证已经完成了 |
| | | // String ywhb = entry.getKey(); |
| | | String ywhb = entry.getKey(); |
| | | List<Map> vehicleIdTotalList = entry.getValue(); |
| | | Map<String, Integer> totalAbcMap = new HashMap(3); // 总计信息 |
| | | totalAbcMap.put("A", 0); |
| | |
| | | for (Map map : vehicleIdTotalList) { |
| | | String hw = (String) map.get("tdmx_hwmc"); |
| | | String pch = (String) map.get("tdmx_pch"); |
| | | if("".equals(cph)) cph = (String) map.get("tdmx_fdcph"); |
| | | if(StringUtils.isBlank(cph)) cph = (String) map.get("tdmx_fdcph"); |
| | | Integer zcbz = (Integer) map.get("tdmx_zcbz"); |
| | | String hh = hw.replaceAll("\\-.*",""); |
| | | hh = hh.substring(hh.length()-2); // 取最后两位 |
| | |
| | | totalAbcMap.get("A") + totalAbcMap.get("B") + totalAbcMap.get("C")) { // 非当前车牌号,已经装车完成但是未出厂 |
| | | continue; |
| | | }*/ |
| | | if(totalAbcMap.get("B")==0 && totalAbcMap.get("C")==0 && totalAbcMap.get("A")==0) { |
| | | continue; |
| | | } |
| | | str2 += String.format(formatStr, cph, fillWithZero(abcMap.get("A")), fillWithZero(totalAbcMap.get("A")), |
| | | fillWithZero(abcMap.get("B")), fillWithZero(totalAbcMap.get("B")), |
| | | fillWithZero(abcMap.get("C")), fillWithZero(totalAbcMap.get("C"))); |
| | | log.info(ywhb + "投屏准备完成,开始准备语音。"); |
| | | // 开始准备语音 |
| | | int total = 0; |
| | | if(currA && abcMap.get("A") == totalAbcMap.get("A")) { // 当前车在A区装车完成 |
| | | if(currA && abcMap.get("A") == totalAbcMap.get("A") && totalAbcMap.get("A")>0) { // 当前车在A区装车完成 |
| | | total = totalAbcMap.get("A"); |
| | | } |
| | | if(currB && abcMap.get("B") == totalAbcMap.get("B")) {// 当前车在B区装车完成 |
| | | if(currB && abcMap.get("B") == totalAbcMap.get("B") && totalAbcMap.get("B")>0) {// 当前车在B区装车完成 |
| | | total = totalAbcMap.get("B"); |
| | | } |
| | | if(currC && abcMap.get("C") == totalAbcMap.get("C")) {// 当前车在C区装车完成 |
| | | if(currC && abcMap.get("C") == totalAbcMap.get("C") && totalAbcMap.get("C")>0) {// 当前车在C区装车完成 |
| | | total = totalAbcMap.get("C"); |
| | | } |
| | | if(total > 0) { // 播放语音,请离开区域 |
| | | speakParam.clear(); |
| | | String speakTxt=null ; |
| | | if( (abcMap.get("A")>0 && totalAbcMap.get("B")==0 && totalAbcMap.get("C")==0) || |
| | | (abcMap.get("B")>0 && totalAbcMap.get("A")==0 && totalAbcMap.get("C")==0) || |
| | | (abcMap.get("C")>0 && totalAbcMap.get("B")==0 && totalAbcMap.get("D")==0) |
| | | ) { // 只有一个区域有货物 |
| | | speakTxt= String.format(speakTxtFormatStr1, cph, total); |
| | | }else if(totalAbcMap.get("A")>0 && totalAbcMap.get("B")>0 && |
| | | (totalAbcMap.get("C")==0 || totalAbcMap.get("C") == abcMap.get("C"))){ // AB都有货 C区已完或无货 |
| | | if(totalAbcMap.get("C")>0 && abcMap.get("A")< totalAbcMap.get("A") && abcMap.get("B")< totalAbcMap.get("B")) { // C装完AB未装完 |
| | | speakTxt= String.format(speakTxtFormatStr3, cph,"C", total,"A","B"); |
| | | } else if(abcMap.get("A")== totalAbcMap.get("A") && abcMap.get("B")< totalAbcMap.get("B")) { //A完B未完 |
| | | speakTxt = String.format(speakTxtFormatStr2, cph, "A", total, "B"); |
| | | }else if(abcMap.get("B")== totalAbcMap.get("B") && abcMap.get("A")< totalAbcMap.get("A")) {//B完A未完 |
| | | speakTxt = String.format(speakTxtFormatStr2, cph, "B", total, "A"); |
| | | }else { // 全部装完 |
| | | speakTxt= String.format(speakTxtFormatStr1, cph, total); |
| | | } |
| | | }else if(totalAbcMap.get("C")>0 && totalAbcMap.get("B")>0 && |
| | | (totalAbcMap.get("A")==0 || totalAbcMap.get("A") == abcMap.get("A")) ){ //BC有货 A区已完或无货 |
| | | if(totalAbcMap.get("A")>0 && abcMap.get("C")< totalAbcMap.get("C") && abcMap.get("B")< totalAbcMap.get("B")) { // A装完BC未装完 |
| | | speakTxt= String.format(speakTxtFormatStr3, cph,"A", total,"B","C"); |
| | | } else if(abcMap.get("C")== totalAbcMap.get("C") && abcMap.get("B")< totalAbcMap.get("B")) { // C完B未装完 |
| | | speakTxt = String.format(speakTxtFormatStr2, cph, "C", total, "B"); |
| | | }else if(abcMap.get("B")== totalAbcMap.get("B") && abcMap.get("C")< totalAbcMap.get("C")) {// B完C未装完 |
| | | speakTxt = String.format(speakTxtFormatStr2, cph, "B", total, "C"); |
| | | }else { // 全部装完 |
| | | speakTxt= String.format(speakTxtFormatStr1, cph, total); |
| | | } |
| | | }else if (totalAbcMap.get("A")>0 && totalAbcMap.get("C")>0 && |
| | | (totalAbcMap.get("B")==0 || totalAbcMap.get("B") == abcMap.get("B")) ) { //AC有货 |
| | | if(totalAbcMap.get("B")>0 && abcMap.get("A")< totalAbcMap.get("A") && abcMap.get("C")< totalAbcMap.get("C")) { |
| | | speakTxt= String.format(speakTxtFormatStr3, cph,"B", total,"A","C"); |
| | | } else if(abcMap.get("A")== totalAbcMap.get("A") && abcMap.get("C")< totalAbcMap.get("C")) { // A装完C未装完 |
| | | speakTxt = String.format(speakTxtFormatStr2, cph, "A", total, "C"); |
| | | }else if(abcMap.get("C")== totalAbcMap.get("C") && abcMap.get("A")< totalAbcMap.get("A")) {// C装完A未装完 |
| | | speakTxt = String.format(speakTxtFormatStr2, cph, "C", total, "A"); |
| | | }else { // 全部装完 |
| | | speakTxt= String.format(speakTxtFormatStr1, cph, total); |
| | | } |
| | | }else if(totalAbcMap.get("A")>0 && totalAbcMap.get("B")>0 && totalAbcMap.get("C")>0) { // 3区都有货物,且只有一个取装完了 |
| | | if(abcMap.get("A")>0 && abcMap.get("B")<totalAbcMap.get("B") && abcMap.get("C")<totalAbcMap.get("C")) { |
| | | speakTxt= String.format(speakTxtFormatStr3, cph,"A", total,"B","C"); |
| | | } else if(abcMap.get("B")>0 && abcMap.get("C")==0 && abcMap.get("A")==0) { |
| | | speakTxt= String.format(speakTxtFormatStr3, cph,"B", total,"A","C"); |
| | | } else if(abcMap.get("C")>0 && abcMap.get("A")==0 && abcMap.get("B")==0) { |
| | | speakTxt= String.format(speakTxtFormatStr3, cph,"C", total,"A","B"); |
| | | } else { // 全部装完 |
| | | speakTxt= String.format(speakTxtFormatStr1, cph, total); |
| | | } |
| | | } else { |
| | | speakTxt= String.format(speakTxtFormatStr1, cph, total); |
| | | try { |
| | | String speakTxt = startToSpeak(cph,total,abcMap,totalAbcMap); |
| | | if(StringUtils.isNotBlank(speakTxt)) { |
| | | log.info("SpeakTxt:"+ speakTxt); |
| | | speakParam.put("SpeakTxt", speakTxt); |
| | | } |
| | | speakParam.put("SpeakTxt", speakTxt); |
| | | log.info("SpeakTxt:"+ speakTxt); |
| | | }catch (Exception e){ |
| | | log.error("准备语音出错!" + e.getMessage(),e); |
| | | } |
| | | |
| | | // 准备语音结束 |
| | | // 单辆车的单个业务单的信息结束 |
| | | } |
| | | if(StringUtils.isBlank(str2)) { |
| | |
| | | |
| | | } |
| | | |
| | | /** |
| | | * 准备语音 |
| | | * @param cph 车牌号 |
| | | * @param total 当前区总数 |
| | | * @param abcMap A、B、C为key的区已装数目 |
| | | * @param totalAbcMap A、B、C为key的区总数 |
| | | * @return |
| | | */ |
| | | String startToSpeak(String cph, int total,Map<String,Integer> abcMap,Map<String,Integer> totalAbcMap) { |
| | | String speakTxt=null ; |
| | | if(total > 0) { // 播放语音,请离开区域 |
| | | String speakTxtFormatStr1 = "车号%s ,装货%d件已完成,请司机清点货物后尽快驶离装货区。"; |
| | | // 只有2个区 |
| | | String speakTxtFormatStr2 = "车号%s,%s区装货%d件已全部扫描完成,请司机清点货物后去%s区装货。"; |
| | | // 只有3个区 |
| | | String speakTxtFormatStr3 = "车号%s,%s区装货%d件已全部扫描完成,请司机清点货物后去%s区%s区装货。"; |
| | | |
| | | if( (abcMap.get("A")>0 && totalAbcMap.get("B")==0 && totalAbcMap.get("C")==0) || |
| | | (abcMap.get("B")>0 && totalAbcMap.get("A")==0 && totalAbcMap.get("C")==0) || |
| | | (abcMap.get("C")>0 && totalAbcMap.get("B")==0 && totalAbcMap.get("D")==0) |
| | | ) { // 只有一个区域有货物 |
| | | speakTxt= String.format(speakTxtFormatStr1, cph, total); |
| | | }else if(totalAbcMap.get("A")>0 && totalAbcMap.get("B")>0 && |
| | | (totalAbcMap.get("C")==0 || totalAbcMap.get("C") == abcMap.get("C"))){ // AB都有货 C区已完或无货 |
| | | if(totalAbcMap.get("C")>0 && abcMap.get("A")< totalAbcMap.get("A") && abcMap.get("B")< totalAbcMap.get("B")) { // C装完AB未装完 |
| | | speakTxt= String.format(speakTxtFormatStr3, cph,"C", total,"A","B"); |
| | | } else if(abcMap.get("A")== totalAbcMap.get("A") && abcMap.get("B")< totalAbcMap.get("B")) { //A完B未完 |
| | | speakTxt = String.format(speakTxtFormatStr2, cph, "A", total, "B"); |
| | | }else if(abcMap.get("B")== totalAbcMap.get("B") && abcMap.get("A")< totalAbcMap.get("A")) {//B完A未完 |
| | | speakTxt = String.format(speakTxtFormatStr2, cph, "B", total, "A"); |
| | | }else { // 全部装完 |
| | | speakTxt= String.format(speakTxtFormatStr1, cph, total); |
| | | } |
| | | }else if(totalAbcMap.get("C")>0 && totalAbcMap.get("B")>0 && |
| | | (totalAbcMap.get("A")==0 || totalAbcMap.get("A") == abcMap.get("A")) ){ //BC有货 A区已完或无货 |
| | | if(totalAbcMap.get("A")>0 && abcMap.get("C")< totalAbcMap.get("C") && abcMap.get("B")< totalAbcMap.get("B")) { // A装完BC未装完 |
| | | speakTxt= String.format(speakTxtFormatStr3, cph,"A", total,"B","C"); |
| | | } else if(abcMap.get("C")== totalAbcMap.get("C") && abcMap.get("B")< totalAbcMap.get("B")) { // C完B未装完 |
| | | speakTxt = String.format(speakTxtFormatStr2, cph, "C", total, "B"); |
| | | }else if(abcMap.get("B")== totalAbcMap.get("B") && abcMap.get("C")< totalAbcMap.get("C")) {// B完C未装完 |
| | | speakTxt = String.format(speakTxtFormatStr2, cph, "B", total, "C"); |
| | | }else { // 全部装完 |
| | | speakTxt= String.format(speakTxtFormatStr1, cph, total); |
| | | } |
| | | }else if (totalAbcMap.get("A")>0 && totalAbcMap.get("C")>0 && |
| | | (totalAbcMap.get("B")==0 || totalAbcMap.get("B") == abcMap.get("B")) ) { //AC有货 |
| | | if(totalAbcMap.get("B")>0 && abcMap.get("A")< totalAbcMap.get("A") && abcMap.get("C")< totalAbcMap.get("C")) { |
| | | speakTxt= String.format(speakTxtFormatStr3, cph,"B", total,"A","C"); |
| | | } else if(abcMap.get("A")== totalAbcMap.get("A") && abcMap.get("C")< totalAbcMap.get("C")) { // A装完C未装完 |
| | | speakTxt = String.format(speakTxtFormatStr2, cph, "A", total, "C"); |
| | | }else if(abcMap.get("C")== totalAbcMap.get("C") && abcMap.get("A")< totalAbcMap.get("A")) {// C装完A未装完 |
| | | speakTxt = String.format(speakTxtFormatStr2, cph, "C", total, "A"); |
| | | }else { // 全部装完 |
| | | speakTxt= String.format(speakTxtFormatStr1, cph, total); |
| | | } |
| | | }else if(totalAbcMap.get("A")>0 && totalAbcMap.get("B")>0 && totalAbcMap.get("C")>0) { // 3区都有货物,且只有一个取装完了 |
| | | if(abcMap.get("A")>0 && abcMap.get("B")<totalAbcMap.get("B") && abcMap.get("C")<totalAbcMap.get("C")) { |
| | | speakTxt= String.format(speakTxtFormatStr3, cph,"A", total,"B","C"); |
| | | } else if(abcMap.get("B")>0 && abcMap.get("C")==0 && abcMap.get("A")==0) { |
| | | speakTxt= String.format(speakTxtFormatStr3, cph,"B", total,"A","C"); |
| | | } else if(abcMap.get("C")>0 && abcMap.get("A")==0 && abcMap.get("B")==0) { |
| | | speakTxt= String.format(speakTxtFormatStr3, cph,"C", total,"A","B"); |
| | | } else { // 全部装完 |
| | | speakTxt= String.format(speakTxtFormatStr1, cph, total); |
| | | } |
| | | } else { |
| | | speakTxt= String.format(speakTxtFormatStr1, cph, total); |
| | | } |
| | | } |
| | | return speakTxt; |
| | | } |
| | | |
| | | @Override |
| | | public void sendToYrLed(String currPch) { |
| | | // 状态 一磅后,待装;PDA扫码 在装; 二次过磅后消失 |