Przeglądaj źródła

南沙温湿度对接导入增加修正值的计算

WuYi 6 godzin temu
rodzic
commit
e28575af08

+ 73 - 39
ibps-provider-root/modules/provider-business/src/main/java/com/lc/ibps/business/thirtyparty/service/impl/NanShaWsdServiceImpl.java

@@ -19,6 +19,7 @@ import org.springframework.stereotype.Service;
 import org.springframework.web.bind.annotation.RequestParam;
 import org.springframework.web.multipart.MultipartFile;
 
+import java.text.DecimalFormat;
 import java.util.Date;
 import java.util.HashMap;
 import java.util.List;
@@ -227,37 +228,43 @@ public class NanShaWsdServiceImpl extends WsdBaseServiceImpl implements NanShaWs
             String id = StrUtil.str(map.get("id_"));
             String date = StrUtil.str(map.get("bian_zhi_shi_jian"));
             String code = StrUtil.str(map.get("bing_xiang_bian_h"));
-            String sql2 = "SELECT *from t_dsfwsdjlb WHERE cai_ji_ri_qi_='"+date+"' and yuan_she_bei_bian='"+code+"' ORDER BY cai_ji_shi_jian_";
+            String sql2 = "SELECT t_dsfwsdjlb.* ,t_wsdcjpzb.wen_du_xiu_zheng_,t_wsdcjpzb.shi_du_xiu_zheng_ from t_dsfwsdjlb " +
+                    " left join t_wsdcjpzb on t_dsfwsdjlb.cai_ji_qi_id_ =t_wsdcjpzb.cai_ji_qi_id_  " +
+                    " WHERE t_dsfwsdjlb.cai_ji_ri_qi_='"+date+"' and t_dsfwsdjlb.yuan_she_bei_bian='"+code+"' ORDER BY cai_ji_shi_jian_";
             List<Map<String, Object>> dayList = (List<Map<String, Object>>) commonDao.query(sql2);
             if (BeanUtils.isEmpty(dayList))continue;
             String zhuangtai = "正常";
             String shi_ji_shi_jian_ = "";
             String wdfw = "";String sdfw = "";
             JSONArray params = new JSONArray();
+            DecimalFormat df = new DecimalFormat("#.#");
             for (Map<String,Object> day : dayList){
                 double value = Double.parseDouble(StrUtil.str(day.get("wen_shi_du_zhi_")));
                 double max = Double.parseDouble(StrUtil.str(day.get("zui_da_zhi_")));
                 double min = Double.parseDouble(StrUtil.str(day.get("zui_xiao_zhi_")));
+                double wenDuXiuZheng = Double.parseDouble(StrUtil.str(day.get("wen_du_xiu_zheng_")));
+                double shiDuXiuZheng = Double.parseDouble(StrUtil.str(day.get("shi_du_xiu_zheng_")));
+                double calculate;
                 String type = StrUtil.str(day.get("shu_ju_lei_xing_"));
                 String status = StrUtil.str(day.get("shi_fou_shi_kong_")).equals("是")?"失控":"正常";
-                if (status.equals("失控")){
-                    zhuangtai = "失控";
-                }
+                String time = StrUtil.str(day.get("shi_ke_"));
+                JSONObject tempObj = new JSONObject();
+                JSONArray tempRange = new JSONArray();
+                tempRange.add(min);
+                tempRange.add(max);
                 shi_ji_shi_jian_ = StrUtil.str(day.get("cai_ji_shi_jian_"));
                 if (type.equals("温度")){
                     wdfw = "温度:"+min+"~"+max+"℃";
+                    tempObj.put("fixValue",StrUtil.str(day.get("wen_du_xiu_zheng_")));
+                    calculate = value + wenDuXiuZheng;
                 }else {
                     sdfw = "湿度:"+min+"~"+max+"%";
+                    tempObj.put("fixValue",StrUtil.str(day.get("shi_du_xiu_zheng_")));
+                    calculate = value + shiDuXiuZheng;
                 }
-                String time = StrUtil.str(day.get("shi_ke_"));
-                JSONObject tempObj = new JSONObject();
-                JSONArray tempRange = new JSONArray();
-                tempRange.add(min);
-                tempRange.add(max);
                 tempObj.put("range",tempRange);
-                tempObj.put("fixValue","");
                 tempObj.put("value",value);
-                tempObj.put("result",value);
+                tempObj.put("result",df.format(calculate));
                 tempObj.put("status",status);
                 tempObj.put("unit",type.equals("温度")?"℃":"%");
                 tempObj.put("label", time +"点"+ type);
@@ -281,37 +288,47 @@ public class NanShaWsdServiceImpl extends WsdBaseServiceImpl implements NanShaWs
             String id = StrUtil.str(map.get("id_"));
             String date = StrUtil.str(map.get("bian_zhi_shi_jian"));
             String code = StrUtil.str(map.get("wen_du_ji_bian_ha"));
-            String sql2 = "SELECT *from t_dsfwsdjlb WHERE cai_ji_ri_qi_='"+date+"' and yuan_she_bei_bian='"+code+"' ORDER BY cai_ji_shi_jian_";
+            String sql2 = "SELECT t_dsfwsdjlb.* ,t_wsdcjpzb.wen_du_xiu_zheng_,t_wsdcjpzb.shi_du_xiu_zheng_ from t_dsfwsdjlb " +
+                    " left join t_wsdcjpzb on t_dsfwsdjlb.cai_ji_qi_id_ =t_wsdcjpzb.cai_ji_qi_id_  " +
+                    " WHERE t_dsfwsdjlb.cai_ji_ri_qi_='"+date+"' and t_dsfwsdjlb.yuan_she_bei_bian='"+code+"' ORDER BY cai_ji_shi_jian_";
             List<Map<String, Object>> dayList = (List<Map<String, Object>>) commonDao.query(sql2);
             if (BeanUtils.isEmpty(dayList))continue;
             String zhuangtai = "正常";
             String shi_ji_shi_jian_ = "";
             String wdfw = "";String sdfw = "";
             JSONArray params = new JSONArray();
+            DecimalFormat df = new DecimalFormat("#.#");
             for (Map<String,Object> day : dayList){
-                double value = Double.parseDouble(StrUtil.str(day.get("wen_shi_du_zhi_")));
-                double max = Double.parseDouble(StrUtil.str(day.get("zui_da_zhi_")));
-                double min = Double.parseDouble(StrUtil.str(day.get("zui_xiao_zhi_")));
+                //cai_ji_qi_id_
+                double value = Double.parseDouble(StrUtil.str(day.get("wen_shi_du_zhi_")));//原值
+                double max = Double.parseDouble(StrUtil.str(day.get("zui_da_zhi_"))); //最大值
+                double min = Double.parseDouble(StrUtil.str(day.get("zui_xiao_zhi_")));//最小值
+                double wenDuXiuZheng = Double.parseDouble(StrUtil.str(day.get("wen_du_xiu_zheng_")));
+                double shiDuXiuZheng = Double.parseDouble(StrUtil.str(day.get("shi_du_xiu_zheng_")));
+                double calculate;
                 String type = StrUtil.str(day.get("shu_ju_lei_xing_"));
                 String status = StrUtil.str(day.get("shi_fou_shi_kong_")).equals("是")?"失控":"正常";
                 if (status.equals("失控")){
                     zhuangtai = "失控";
                 }
                 shi_ji_shi_jian_ = StrUtil.str(day.get("cai_ji_shi_jian_"));
-                if (type.equals("温度")){
-                    wdfw = "温度:"+min+"~"+max+"℃";
-                }else {
-                    sdfw = "湿度:"+min+"~"+max+"%";
-                }
                 String time = StrUtil.str(day.get("shi_ke_"));
                 JSONObject tempObj = new JSONObject();
                 JSONArray tempRange = new JSONArray();
                 tempRange.add(min);
                 tempRange.add(max);
+                if (type.equals("温度")){
+                    wdfw = "温度:"+min+"~"+max+"℃";
+                    tempObj.put("fixValue",StrUtil.str(day.get("wen_du_xiu_zheng_")));
+                    calculate = value + wenDuXiuZheng;
+                }else {
+                    sdfw = "湿度:"+min+"~"+max+"%";
+                    tempObj.put("fixValue",StrUtil.str(day.get("shi_du_xiu_zheng_")));
+                    calculate = value + shiDuXiuZheng;
+                }
                 tempObj.put("range",tempRange);
-                tempObj.put("fixValue","");
                 tempObj.put("value",value);
-                tempObj.put("result",value);
+                tempObj.put("result",df.format(calculate));
                 tempObj.put("status",status);
                 tempObj.put("unit",type.equals("温度")?"℃":"%");
                 tempObj.put("label", time +"点"+ type);
@@ -336,37 +353,45 @@ public class NanShaWsdServiceImpl extends WsdBaseServiceImpl implements NanShaWs
             String date = StrUtil.str(map.get("bian_zhi_shi_jian"));
             String code = StrUtil.str(map.get("she_bei_bian_hao_"));
             code = code + " " + StrUtil.str(map.get("she_bei_ming_chen"));
-            String sql2 = "SELECT *from t_dsfwsdjlb WHERE cai_ji_ri_qi_='"+date+"' and yuan_she_bei_bian='"+code+"' ORDER BY cai_ji_shi_jian_";
+            String sql2 = "SELECT t_dsfwsdjlb.* ,t_wsdcjpzb.wen_du_xiu_zheng_,t_wsdcjpzb.shi_du_xiu_zheng_ from t_dsfwsdjlb " +
+                    " left join t_wsdcjpzb on t_dsfwsdjlb.cai_ji_qi_id_ =t_wsdcjpzb.cai_ji_qi_id_  " +
+                    " WHERE t_dsfwsdjlb.cai_ji_ri_qi_='"+date+"' and t_dsfwsdjlb.yuan_she_bei_bian='"+code+"' ORDER BY cai_ji_shi_jian_";
             List<Map<String, Object>> dayList = (List<Map<String, Object>>) commonDao.query(sql2);
             if (BeanUtils.isEmpty(dayList))continue;
             String zhuangtai = "正常";
             String shi_ji_shi_jian_ = "";
             String wdfw = "";String sdfw = "";
             JSONArray params = new JSONArray();
+            DecimalFormat df = new DecimalFormat("#.#");
             for (Map<String,Object> day : dayList){
                 double value = Double.parseDouble(StrUtil.str(day.get("wen_shi_du_zhi_")));
                 double max = Double.parseDouble(StrUtil.str(day.get("zui_da_zhi_")));
                 double min = Double.parseDouble(StrUtil.str(day.get("zui_xiao_zhi_")));
+                double wenDuXiuZheng = Double.parseDouble(StrUtil.str(day.get("wen_du_xiu_zheng_")));
+                double shiDuXiuZheng = Double.parseDouble(StrUtil.str(day.get("shi_du_xiu_zheng_")));
+                double calculate;
                 String type = StrUtil.str(day.get("shu_ju_lei_xing_"));
                 String status = StrUtil.str(day.get("shi_fou_shi_kong_")).equals("是")?"失控":"正常";
                 if (status.equals("失控")){
                     zhuangtai = "失控";
                 }
                 shi_ji_shi_jian_ = StrUtil.str(day.get("cai_ji_shi_jian_"));
-                if (type.equals("温度")){
-                    wdfw = "温度:"+min+"~"+max+"℃";
-                }else {
-                    sdfw = "湿度:"+min+"~"+max+"%";
-                }
                 String time = StrUtil.str(day.get("shi_ke_"));
                 JSONObject tempObj = new JSONObject();
                 JSONArray tempRange = new JSONArray();
                 tempRange.add(min);
                 tempRange.add(max);
+                if (type.equals("温度")){
+                    wdfw = "温度:"+min+"~"+max+"℃";
+                    tempObj.put("fixValue",StrUtil.str(day.get("wen_du_xiu_zheng_")));
+                    calculate = value + wenDuXiuZheng;
+                }else {
+                    sdfw = "湿度:"+min+"~"+max+"%";
+                    tempObj.put("fixValue",StrUtil.str(day.get("shi_du_xiu_zheng_")));
+                    calculate = value + shiDuXiuZheng;
+                }
                 tempObj.put("range",tempRange);
-                tempObj.put("fixValue","");
-                tempObj.put("value",value);
-                tempObj.put("result",value);
+                tempObj.put("result",df.format(calculate));
                 tempObj.put("status",status);
                 tempObj.put("unit",type.equals("温度")?"℃":"%");
                 tempObj.put("label", time +"点"+ type);
@@ -391,36 +416,45 @@ public class NanShaWsdServiceImpl extends WsdBaseServiceImpl implements NanShaWs
             String id = StrUtil.str(map.get("id_"));
             String date = StrUtil.str(map.get("bian_zhi_shi_jian"));
             String code = StrUtil.str(map.get("yin_liang_gui_bia"));
-            String sql2 = "SELECT *from t_dsfwsdjlb WHERE cai_ji_ri_qi_='"+date+"' and yuan_she_bei_bian='"+code+"' ORDER BY cai_ji_shi_jian_";
+            String sql2 = "SELECT t_dsfwsdjlb.* ,t_wsdcjpzb.wen_du_xiu_zheng_,t_wsdcjpzb.shi_du_xiu_zheng_ from t_dsfwsdjlb " +
+                    " left join t_wsdcjpzb on t_dsfwsdjlb.cai_ji_qi_id_ =t_wsdcjpzb.cai_ji_qi_id_  " +
+                    " WHERE t_dsfwsdjlb.cai_ji_ri_qi_='"+date+"' and t_dsfwsdjlb.yuan_she_bei_bian='"+code+"' ORDER BY cai_ji_shi_jian_";
             List<Map<String, Object>> dayList = (List<Map<String, Object>>) commonDao.query(sql2);
             if (BeanUtils.isEmpty(dayList))continue;
             String zhuangtai = "正常";
             String shi_ji_shi_jian_ = "";
             String wdfw = "";String sdfw = "";
             JSONArray params = new JSONArray();
+            DecimalFormat df = new DecimalFormat("#.#");
             for (Map<String,Object> day : dayList){
                 double value = Double.parseDouble(StrUtil.str(day.get("wen_shi_du_zhi_")));
                 double max = Double.parseDouble(StrUtil.str(day.get("zui_da_zhi_")));
                 double min = Double.parseDouble(StrUtil.str(day.get("zui_xiao_zhi_")));
+                double wenDuXiuZheng = Double.parseDouble(StrUtil.str(day.get("wen_du_xiu_zheng_")));
+                double shiDuXiuZheng = Double.parseDouble(StrUtil.str(day.get("shi_du_xiu_zheng_")));
+                double calculate;
                 String type = StrUtil.str(day.get("shu_ju_lei_xing_"));
                 String status = StrUtil.str(day.get("shi_fou_shi_kong_")).equals("是")?"失控":"正常";
                 if (status.equals("失控")){
                     zhuangtai = "失控";
                 }
                 shi_ji_shi_jian_ = StrUtil.str(day.get("cai_ji_shi_jian_"));
-                if (type.equals("温度")){
-                    wdfw = "温度:"+min+"~"+max+"℃";
-                }else {
-                    sdfw = "湿度:"+min+"~"+max+"%";
-                }
                 String time = StrUtil.str(day.get("shi_ke_"));
                 JSONObject tempObj = new JSONObject();
                 JSONArray tempRange = new JSONArray();
                 tempRange.add(min);
                 tempRange.add(max);
+                if (type.equals("温度")){
+                    wdfw = "温度:"+min+"~"+max+"℃";
+                    tempObj.put("fixValue",StrUtil.str(day.get("wen_du_xiu_zheng_")));
+                    calculate = value + wenDuXiuZheng;
+                }else {
+                    sdfw = "湿度:"+min+"~"+max+"%";
+                    tempObj.put("fixValue",StrUtil.str(day.get("shi_du_xiu_zheng_")));
+                    calculate = value + shiDuXiuZheng;
+                }
                 tempObj.put("range",tempRange);
-                tempObj.put("fixValue","");
-                tempObj.put("value",value);
+                tempObj.put("value",df.format(calculate));
                 tempObj.put("result",value);
                 tempObj.put("status",status);
                 tempObj.put("unit",type.equals("温度")?"℃":"%");