diff --git a/measurement/src/main/java/com/ruoyi/operation/service/impl/getPoundWeightData.java b/measurement/src/main/java/com/ruoyi/operation/service/impl/getPoundWeightData.java index 917527c..1e83be0 100644 --- a/measurement/src/main/java/com/ruoyi/operation/service/impl/getPoundWeightData.java +++ b/measurement/src/main/java/com/ruoyi/operation/service/impl/getPoundWeightData.java @@ -3,6 +3,8 @@ package com.ruoyi.operation.service.impl; import com.alibaba.fastjson.JSONObject; import com.ruoyi.basedata.domain.Truepound; import com.ruoyi.basedata.service.ITruepoundService; +import com.ruoyi.common.core.controller.BaseController; +import com.ruoyi.common.core.domain.AjaxResult; import com.ruoyi.common.core.domain.entity.SysDictData; import com.ruoyi.common.utils.DictUtils; import com.ruoyi.common.utils.StringUtils; @@ -19,17 +21,19 @@ import java.io.InputStreamReader; import java.net.HttpURLConnection; import java.net.URL; import java.math.BigDecimal; +import java.util.HashMap; +import java.util.Map; @RestController @RequestMapping("/util/getPound") -public class getPoundWeightData { +public class getPoundWeightData extends BaseController { @Autowired private ISysConfigService sysConfigService; @Autowired private ITruepoundService truepoundService; @GetMapping(value = "/getWeight/{poundid}") - public BigDecimal getPoundWeight(@PathVariable("poundid")String poundid) { + public AjaxResult getPoundWeight(@PathVariable("poundid")String poundid) { Truepound truepound = truepoundService.selectTruepoundById(poundid); if(truepound==null){ throw new RuntimeException("磅点id:"+poundid+"不存在对应的实际磅点不存在"); @@ -46,8 +50,20 @@ public class getPoundWeightData { } String api = sysConfig.getConfigValue()+pound_api; JSONObject jsonObject = doGetRequest(api); + HashMap hashMap = new HashMap<>(); + if(1==1){ + hashMap.put("code", jsonObject.get("code")); + hashMap.put("message", jsonObject.getString("message")); + hashMap.put("data", jsonObject.get("data")); + hashMap.put("return", jsonObject.get("return")); + return success(hashMap); + } if (jsonObject.getIntValue("code") == 0) { - return jsonObject.getBigDecimal("data"); + hashMap.put("code", jsonObject.get("code")); + hashMap.put("message", jsonObject.getString("message")); + hashMap.put("data", jsonObject.get("data")); + hashMap.put("return", jsonObject.get("return")); + return success(hashMap); }else{ String message = jsonObject.getString("message"); throw new RuntimeException(message); @@ -78,7 +94,9 @@ public class getPoundWeightData { } in.close(); - return new JSONObject(response.toString().isEmpty()); + JSONObject jsonObject = JSONObject.parseObject(response.toString()); + jsonObject.put("return",response.toString()); + return jsonObject; } else { JSONObject put = new JSONObject(); put.put("code", 1); diff --git a/ruoyi-ui/src/views/measurement/operation/moltenironpound/index.vue b/ruoyi-ui/src/views/measurement/operation/moltenironpound/index.vue index 82ce4cf..0645af6 100644 --- a/ruoyi-ui/src/views/measurement/operation/moltenironpound/index.vue +++ b/ruoyi-ui/src/views/measurement/operation/moltenironpound/index.vue @@ -908,10 +908,16 @@ export default { //const randomInt = Math.floor(Math.random() * 9900 + 100); // 转换为两位小数,内存中是有限小数 //this.queryParams.weight = new Decimal(randomInt / 100); + this.$modal.loading("正在获取重量,请稍候..."); getWeight(this.queryParams.poundid).then(response => { - this.queryParams.weight = response; - console.log("返参"+response); - }) + debugger + console.log(response); + this.queryParams.weight = response.data.data; + }).then(() => { + this.$modal.closeLoading() + }).catch(() => { + this.$modal.closeLoading() + }); }, //单击主榜单进行单选。 //主榜单单击选中,并将车号进行赋值。(单选) diff --git a/ruoyi-ui/src/views/measurement/operation/outinpound/index.vue b/ruoyi-ui/src/views/measurement/operation/outinpound/index.vue index 08077e5..57cf81d 100644 --- a/ruoyi-ui/src/views/measurement/operation/outinpound/index.vue +++ b/ruoyi-ui/src/views/measurement/operation/outinpound/index.vue @@ -835,12 +835,18 @@ export default { handleGetweight() { // 生成 100 到 10000 的整数(代表 1.00 到 100.00) //const randomInt = Math.floor(Math.random() * 9900 + 100); - getWeight(this.queryParams.poundid).then(response => { - this.queryParams.weight = response; - console.log("返参"+response); - }) // 转换为两位小数,内存中是有限小数 //this.queryParams.weight = new Decimal(randomInt / 100); + this.$modal.loading("正在获取重量,请稍候..."); + getWeight(this.queryParams.poundid).then(response => { + debugger + console.log(response); + this.queryParams.weight = response.data.data; + }).then(() => { + this.$modal.closeLoading() + }).catch(() => { + this.$modal.closeLoading() + }); }, //手动停止定时器 handleStopTimer() { diff --git a/ruoyi-ui/src/views/measurement/operation/shortdispound/index.vue b/ruoyi-ui/src/views/measurement/operation/shortdispound/index.vue index 72cda5e..ff6a581 100644 --- a/ruoyi-ui/src/views/measurement/operation/shortdispound/index.vue +++ b/ruoyi-ui/src/views/measurement/operation/shortdispound/index.vue @@ -1028,10 +1028,16 @@ watch: { // 转换为两位小数,内存中是有限小数 //this.queryParams.weight = new Decimal(randomInt / 100); + this.$modal.loading("正在获取重量,请稍候..."); getWeight(this.queryParams.poundid).then(response => { - this.queryParams.weight = response; - console.log("返参"+response); - }) + debugger + console.log(response); + this.queryParams.weight = response.data.data; + }).then(() => { + this.$modal.closeLoading() + }).catch(() => { + this.$modal.closeLoading() + }); }, //新增皮重,将当前重量上的数据赋值到重量中,并且打开皮重弹窗 getEmpPoundData(){ diff --git a/ruoyi-ui/src/views/measurement/operation/steelpound/index.vue b/ruoyi-ui/src/views/measurement/operation/steelpound/index.vue index b958166..038fcd9 100644 --- a/ruoyi-ui/src/views/measurement/operation/steelpound/index.vue +++ b/ruoyi-ui/src/views/measurement/operation/steelpound/index.vue @@ -716,10 +716,16 @@ export default { // 转换为两位小数,内存中是有限小数 //this.queryParams.weight = new Decimal(randomInt / 100); + this.$modal.loading("正在获取重量,请稍候..."); getWeight(this.queryParams.poundid).then(response => { - this.queryParams.weight = response; - console.log("返参"+response); - }) + debugger + console.log(response); + this.queryParams.weight = response.data.data; + }).then(() => { + this.$modal.closeLoading() + }).catch(() => { + this.$modal.closeLoading() + }); }, //单击主榜单进行单选。