|
@@ -4,27 +4,145 @@ import com.alibaba.fastjson.JSONObject;
|
|
import org.springframework.web.bind.annotation.PostMapping;
|
|
import org.springframework.web.bind.annotation.PostMapping;
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
|
|
+import java.util.HashMap;
|
|
|
|
+import java.util.Map;
|
|
|
|
+
|
|
@RestController
|
|
@RestController
|
|
public class DataController {
|
|
public class DataController {
|
|
|
|
+ public static Long time=0l;
|
|
|
|
+ static {
|
|
|
|
+ time=System.currentTimeMillis();
|
|
|
|
+ }
|
|
|
|
|
|
@PostMapping("/data")
|
|
@PostMapping("/data")
|
|
public JSONObject getData(){
|
|
public JSONObject getData(){
|
|
JSONObject jsonObject=new JSONObject();
|
|
JSONObject jsonObject=new JSONObject();
|
|
|
|
+ Boolean flag=true;
|
|
|
|
+ Map<String,Integer> map=new HashMap<>();
|
|
|
|
+
|
|
|
|
+ //ModbusReader.getData(jsonObject);
|
|
|
|
+
|
|
|
|
+ jsonObject.put("1600",0);
|
|
|
|
+ jsonObject.put("1601",0);
|
|
|
|
+ jsonObject.put("1602",0);
|
|
|
|
+ jsonObject.put("1603",0);
|
|
|
|
+ jsonObject.put("1604",0);
|
|
|
|
+ jsonObject.put("1605",0);
|
|
|
|
+ jsonObject.put("1606",0);
|
|
|
|
+ jsonObject.put("1607",0);
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ //ph值到浊度值
|
|
|
|
+ jsonObject.put("ph",jsonObject.get("1600"));
|
|
|
|
+ jsonObject.put("rjy",jsonObject.get("1601"));
|
|
|
|
+ jsonObject.put("ddl",jsonObject.get("1602"));
|
|
|
|
+ jsonObject.put("dzl",jsonObject.get("1603"));
|
|
|
|
+ jsonObject.put("wdz",jsonObject.get("1604"));
|
|
|
|
+ jsonObject.put("tds",jsonObject.get("1605"));
|
|
|
|
+ jsonObject.put("ryz",jsonObject.get("1606"));
|
|
|
|
+ jsonObject.put("zdz",jsonObject.get("1607"));
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ jsonObject.put("1612",1);
|
|
|
|
+ jsonObject.put("1613",0);
|
|
|
|
+ jsonObject.put("1614",0);
|
|
|
|
+ //设备情况
|
|
|
|
+ int i = Integer.parseInt(jsonObject.get("1612").toString());
|
|
|
|
+ int y = Integer.parseInt(jsonObject.get("1613").toString());
|
|
|
|
+ int z = Integer.parseInt(jsonObject.get("1614").toString());
|
|
|
|
+ jsonObject.put("slqk",jsonObject.get("1612"));
|
|
|
|
+ jsonObject.put("pyqk",jsonObject.get("1613"));
|
|
|
|
+ jsonObject.put("xyqk",jsonObject.get("1614"));
|
|
|
|
+
|
|
|
|
+ if(i==1 || y == 1 || z == 1){
|
|
|
|
+ flag=false;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //出液温度 排液温度
|
|
|
|
+
|
|
|
|
+ jsonObject.put("1600",0);
|
|
|
|
+ jsonObject.put("1601",0);
|
|
|
|
+ jsonObject.put("1602",0);
|
|
|
|
+ jsonObject.put("1603",0);
|
|
|
|
+ jsonObject.put("1604",0);
|
|
|
|
+ jsonObject.put("1605",0);
|
|
|
|
+
|
|
|
|
+ jsonObject.put("cywd",jsonObject.get("1600"));
|
|
|
|
+ jsonObject.put("pywd",jsonObject.get("1601"));
|
|
|
|
+ jsonObject.put("pgwd",jsonObject.get("1602"));
|
|
|
|
+ jsonObject.put("hjwd",jsonObject.get("1603"));
|
|
|
|
|
|
|
|
|
|
|
|
+ jsonObject.put("1000",2);
|
|
|
|
+ jsonObject.put("1001",45);
|
|
|
|
+ jsonObject.put("1002",2);
|
|
|
|
+ jsonObject.put("1003",45);
|
|
|
|
+ jsonObject.put("1004",2);
|
|
|
|
+ jsonObject.put("1005",45);
|
|
|
|
+ jsonObject.put("1006",2);
|
|
|
|
+ jsonObject.put("1007",45);
|
|
|
|
+ jsonObject.put("1008",2);
|
|
|
|
+ jsonObject.put("1009",45);
|
|
|
|
+ jsonObject.put("1010",2);
|
|
|
|
+ jsonObject.put("1011",45);
|
|
|
|
|
|
|
|
|
|
- jsonObject.put("ph","8.970");
|
|
|
|
- jsonObject.put("rjy","8.970");
|
|
|
|
- jsonObject.put("ddl","8.970");
|
|
|
|
- jsonObject.put("dzl","8.970");
|
|
|
|
- jsonObject.put("wdz","8.970");
|
|
|
|
- jsonObject.put("tds","8.970");
|
|
|
|
- jsonObject.put("ryz","8.970");
|
|
|
|
- jsonObject.put("zdz","8.970");
|
|
|
|
|
|
+ int wd1600 = Integer.parseInt(jsonObject.get("1600").toString());
|
|
|
|
+ int wd1000 = Integer.parseInt(jsonObject.get("1000").toString());
|
|
|
|
+ int wd1001 = Integer.parseInt(jsonObject.get("1001").toString());
|
|
|
|
+ if(wd1000 <= wd1600 && wd1600 <= wd1001){
|
|
|
|
+ jsonObject.put("cywdc",0);
|
|
|
|
+ }else{
|
|
|
|
+ jsonObject.put("cywdc",1);
|
|
|
|
+ flag=false;
|
|
|
|
+ }
|
|
|
|
|
|
|
|
+ int wd1601 = Integer.parseInt(jsonObject.get("1601").toString());
|
|
|
|
+ int wd1002 = Integer.parseInt(jsonObject.get("1002").toString());
|
|
|
|
+ int wd1003 = Integer.parseInt(jsonObject.get("1003").toString());
|
|
|
|
+ if(wd1002 <= wd1601 && wd1601 <= wd1003){
|
|
|
|
+ jsonObject.put("pywdc",0);
|
|
|
|
+ }else{
|
|
|
|
+ jsonObject.put("pywdc",1);
|
|
|
|
+ flag=false;
|
|
|
|
+ }
|
|
|
|
|
|
|
|
+ int wd1602 = Integer.parseInt(jsonObject.get("1602").toString());
|
|
|
|
+ int wd1004 = Integer.parseInt(jsonObject.get("1004").toString());
|
|
|
|
+ int wd1005 = Integer.parseInt(jsonObject.get("1005").toString());
|
|
|
|
+ if(wd1004 <= wd1602 && wd1602 <= wd1005){
|
|
|
|
+ jsonObject.put("pgwdc",0);
|
|
|
|
+ }else{
|
|
|
|
+ jsonObject.put("pgwdc",1);
|
|
|
|
+ flag=false;
|
|
|
|
+ }
|
|
|
|
|
|
|
|
+ int wd1603 = Integer.parseInt(jsonObject.get("1603").toString());
|
|
|
|
+ int wd1006 = Integer.parseInt(jsonObject.get("1006").toString());
|
|
|
|
+ int wd1007 = Integer.parseInt(jsonObject.get("1007").toString());
|
|
|
|
+ if(wd1006 <= wd1603 && wd1603 <= wd1007){
|
|
|
|
+ jsonObject.put("hjwdc",0);
|
|
|
|
+ }else{
|
|
|
|
+ jsonObject.put("hjwdc",1);
|
|
|
|
+ flag=false;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ //制冷模式 水箱温度
|
|
|
|
+ jsonObject.put("1610",0);
|
|
|
|
+ jsonObject.put("1605",20);
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ jsonObject.put("zlms",jsonObject.get("1610"));
|
|
|
|
+ jsonObject.put("sxwd",jsonObject.get("1605"));
|
|
|
|
+
|
|
|
|
+ jsonObject.put("status",flag);
|
|
|
|
+ long l = System.currentTimeMillis() - time;
|
|
|
|
+ double hours = l / 3600000.0; // 将毫秒转换为小时,1小时=3600000毫秒
|
|
|
|
+ hours = Math.round(hours * 10) / 10.0; // 保留一位小数
|
|
|
|
+ jsonObject.put("hours",String.valueOf(hours));
|
|
|
|
+
|
|
|
|
|
|
return jsonObject;
|
|
return jsonObject;
|
|
}
|
|
}
|