From cd538c205628f28839323b49b7f77f33196a601f Mon Sep 17 00:00:00 2001 From: zhangnaisong <2434969829@qq.com> Date: 星期四, 11 七月 2024 15:50:42 +0800 Subject: [PATCH] 电磁锁操控加入判断速度为0提交 --- ard-work/src/main/java/com/ruoyi/health/controller/HealthController.java | 124 ++++++++++++++++++++++------------------- 1 files changed, 66 insertions(+), 58 deletions(-) diff --git a/ard-work/src/main/java/com/ruoyi/health/controller/HealthController.java b/ard-work/src/main/java/com/ruoyi/health/controller/HealthController.java index 4ba7c26..24aa518 100644 --- a/ard-work/src/main/java/com/ruoyi/health/controller/HealthController.java +++ b/ard-work/src/main/java/com/ruoyi/health/controller/HealthController.java @@ -81,9 +81,10 @@ //绛夌骇 int count0 = 0,count1 = 0,count2 = 0; //瑁呮暟鎹� - List<HealthVo> healthVos = new ArrayList<>(); + List<TreeDeptWell> treeDeptWells = new ArrayList<>(); if ((int) mapResult.get("code") == 200) { List<Map<String, Object>> listResult = (List<Map<String, Object>>) JSON.parse((String) mapResult.get("resdata")); +// System.out.println(String.valueOf(listResult)); //寰幆寰楀埌鏉冮檺涓嬪尮閰嶆暟鎹� for (int i = 0; i < listResult.size(); i++) { String equipNumber = (String) listResult.get(i).get("EquipNumber"); @@ -93,19 +94,21 @@ if(wellId!=null){ if(wellId.equals(equipNumber)){ //杩斿洖璁惧鏁版嵁 - HealthVo healthVo = new HealthVo(); - healthVo.setId((Integer) listResult.get(i).get("id")); - healthVo.setEquipName((String) listResult.get(i).get("EquipName")); - healthVo.setEquipNumber((String) listResult.get(i).get("EquipNumber")); - healthVo.setEquipLevel((String) listResult.get(i).get("EquipLevel")); - healthVo.setEquipKey((String) listResult.get(i).get("EquipKey")); - healthVo.setMeasureDate((String) listResult.get(i).get("MeasureDate")); - healthVo.setLongitude(list.get(j).getLongitude()); - healthVo.setLatitude(list.get(j).getLatitude()); - healthVo.setAltitude(list.get(j).getAltitude()); - healthVo.setDeptId(list.get(j).getDeptId()); - healthVo.setAncestors(list.get(j).getAncestors()); - healthVos.add(healthVo); + TreeDeptWell treeDeptWell = new TreeDeptWell(); + treeDeptWell.setId((Integer) listResult.get(i).get("id")); + treeDeptWell.setEquipName((String) listResult.get(i).get("EquipName")); + treeDeptWell.setEquipNumber((String) listResult.get(i).get("EquipNumber")); + treeDeptWell.setEquipLevel((String) listResult.get(i).get("EquipLevel")); + treeDeptWell.setEquipKey((String) listResult.get(i).get("EquipKey")); + treeDeptWell.setMeasureDate((String) listResult.get(i).get("MeasureDate")); + treeDeptWell.setLongitude(list.get(j).getLongitude()); + treeDeptWell.setLatitude(list.get(j).getLatitude()); + treeDeptWell.setAltitude(list.get(j).getAltitude()); + treeDeptWell.setDeptId(list.get(j).getDeptId()); + treeDeptWell.setAncestors(list.get(j).getAncestors()); + treeDeptWell.setParentId(list.get(j).getParentId()); + treeDeptWell.setDeptName(list.get(j).getDeptName()); + treeDeptWells.add(treeDeptWell); if(listResult.get(i).get("EquipLevel").equals("0")){ count0++; }else if(listResult.get(i).get("EquipLevel").equals("1")){ @@ -136,16 +139,16 @@ } } //鎶婇儴闂ㄥ眰绾у拰鏁版嵁缁撳悎 - List<TreeDeptWell> treeDeptWells = new ArrayList<>(); +// List<TreeDeptWell> treeDeptWells = new ArrayList<>(); for (int i = 0; i < sysDepts.size(); i++) { + //閮ㄩ棬ID SysDept sysDept = sysDepts.get(i); Long deptId = sysDept.getDeptId(); - List<HealthVo> deptHealths = new ArrayList<>(); - for (int j = 0; j < healthVos.size(); j++) { - HealthVo healthVo = healthVos.get(j); + for (int j = 0; j < treeDeptWells.size(); j++) { + //璁惧鐨勯儴闂↖D + TreeDeptWell healthVo = treeDeptWells.get(j); Long healthDeptId = healthVo.getDeptId(); if(deptId.equals(healthDeptId)){ - deptHealths.add(healthVo); //鐖剁骇缁撴瀯璧嬪�� String thisAncestors = healthVo.getAncestors(); List<String> ancestorsA = Arrays.asList(thisAncestors.split(",")); @@ -155,14 +158,15 @@ //寰幆鏈�缁圠ist鍒ゆ柇鏄惁鏈夎鏁版嵁鐨勭埗绾э紝濡傛灉娌℃湁灏卞~杩涘幓 boolean wellTrue = false; if(ancestor==0){ + //鐖剁被闆嗗悎涓�0鍒欐槸鏈�椤剁骇涓婇潰娌℃湁 wellTrue = true; }else { - if(treeDeptWells.size()>0){ - for (int l = 0; l < treeDeptWells.size(); l++) { - Long treeId = treeDeptWells.get(l).getDeptId(); - if(ancestor.equals(treeId)){ - wellTrue = true; - } + for (int l = 0; l < treeDeptWells.size(); l++) { + //濡傛灉璇ョ埗绫婚泦鍚堝湪缁撴瀯涓凡缁忓瓨鍦ㄥ苟涓斾笉鏄澶囨暟鎹氨涓嶇敤閲嶅娣诲姞浜� + Long treeId = treeDeptWells.get(l).getDeptId(); + Integer id = treeDeptWells.get(l).getId(); + if(ancestor.equals(treeId) && id==null){ + wellTrue = true; } } } @@ -172,32 +176,24 @@ treeDeptWell.setDeptId(ancestor); treeDeptWell.setAncestors(sysDept1.getAncestors()); treeDeptWell.setDeptName(sysDept1.getDeptName()); - treeDeptWell.setOrderNum(sysDept1.getOrderNum()); treeDeptWell.setParentId(sysDept1.getParentId()); treeDeptWells.add(treeDeptWell); } } } } - if(deptHealths.size()>0){ - //鏈夎澶囧睍绀� - TreeDeptWell treeDeptWell = new TreeDeptWell(); - treeDeptWell.setDeptId(deptId); - treeDeptWell.setAncestors(sysDept.getAncestors()); - treeDeptWell.setDeptName(sysDept.getDeptName()); - treeDeptWell.setOrderNum(sysDept.getOrderNum()); - treeDeptWell.setParentId(sysDept.getParentId()); - treeDeptWell.setWell(deptHealths); - treeDeptWells.add(treeDeptWell); - } } - List<TreeSelectWell> tree = sysDeptService.wellTree(treeDeptWells); - TreeSelectWellJson treeSelectWellJson = new TreeSelectWellJson(); - treeSelectWellJson.setWellList(tree); - treeSelectWellJson.setCount0(count0); - treeSelectWellJson.setCount1(count1); - treeSelectWellJson.setCount2(count2); - return Results.succeed(treeSelectWellJson); + if(treeDeptWells.size()>0){ + List<TreeDeptWell> tree = sysDeptService.wellTree(treeDeptWells); + TreeSelectWellJson treeSelectWellJson = new TreeSelectWellJson(); + treeSelectWellJson.setWellList(tree); + treeSelectWellJson.setCount0(count0); + treeSelectWellJson.setCount1(count1); + treeSelectWellJson.setCount2(count2); + return Results.succeed(treeSelectWellJson); + }else { + return Results.error("鏃犲尮閰嶆暟鎹�"); + } } else { //閿欒鎻愮ず return Results.error((String) mapResult.get("errmsg")); @@ -305,7 +301,7 @@ @PreAuthorize("@ss.hasPermi('sy:syCar:getTrend')") @ApiOperation("鑾峰彇鏌愭补浜曚竴娈垫椂闂寸殑娴嬮噺瓒嬪娍") @GetMapping("getTrend") - public Results getTrend(GetTrendParam getTrendParam){ + public JSONObject getTrend(GetTrendParam getTrendParam){ String url = configService.getHealth(); Map<String , Object> map = new HashMap<String , Object>(); map.put("MeasureKey", getTrendParam.getMeasureKey()); @@ -314,29 +310,41 @@ JSONObject j = new JSONObject(); String result = ARDSoapUtil.postSoapResult(url ,"GetTrend" , map); if ("".equals(result)){ - return Results.succeed("娌℃湁娴嬬偣淇℃伅"); + j.put("msg", "娌℃湁娴嬬偣淇℃伅"); + j.put("code", 500); } Map<String,Object> mapResult = (Map<String, Object>) JSON.parse((String)result); if ( (int) mapResult.get("code") == 200){ j.put("code", mapResult.get("code")); List<Map<String , Object>> listResult = (List<Map<String, Object>>)JSON.parse((String)mapResult.get("resdata")); - for(int i = 0 ; i<listResult.size(); i++){ - Map<String , Object> mapTemp = listResult.get(i); - int id = (Integer)mapTemp.get("id"); //涓婚敭id - BigDecimal value = (BigDecimal)mapTemp.get("Value"); //鏁板�� - String measureStr = (String)mapTemp.get("MeasureDate"); //娴嬮噺鏃堕棿 - measureStr = measureStr.substring(measureStr.indexOf("(")+1, measureStr.indexOf(")",2)); - SimpleDateFormat f = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); - String measureDate = f.format(Long.valueOf(measureStr)); - mapTemp.put("MeasureDate", measureDate); - j.put(id +"" , mapTemp); + + if(listResult.size()>0){ + for(int i = 0 ; i<listResult.size(); i++){ + Map<String , Object> mapTemp = listResult.get(i); + //BigDecimal value = (BigDecimal)mapTemp.get("Value"); //鏁板�� + BigDecimal value = null; //鏁板�� + try{ + value = (BigDecimal)mapTemp.get("Value"); + }catch(Exception e){ + value = BigDecimal.valueOf(((Number)mapTemp.get("Value")).floatValue()); + } + String measureStr = (String)mapTemp.get("MeasureDate"); //娴嬮噺鏃堕棿 + measureStr = measureStr.substring(measureStr.indexOf("(")+1, measureStr.indexOf(")",2)); + SimpleDateFormat f = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + String measureDate = f.format(Long.valueOf(measureStr)); + mapTemp.put("MeasureDate", measureDate); + mapTemp.put("Value", value.setScale(2, BigDecimal.ROUND_HALF_UP)); + } + j.put("data",listResult); + }else { + j.put("data",new ArrayList<>()); } }else{ //閿欒鎻愮ず - j.put("errmsg", mapResult.get("errmsg")); + j.put("msg", mapResult.get("errmsg")); j.put("code", mapResult.get("code")); } - return Results.succeed(j); + return j; } @PreAuthorize("@ss.hasPermi('sy:syCar:getWaveDataByIndex')") -- Gitblit v1.9.3