|
|
@@ -1,12 +1,9 @@
|
|
|
package com.lc.ibps.business.thirtyparty.service.impl;
|
|
|
|
|
|
-import com.alibaba.fastjson.JSONArray;
|
|
|
-import com.alibaba.fastjson.JSONObject;
|
|
|
import com.lc.ibps.api.base.constants.StateEnum;
|
|
|
import com.lc.ibps.base.core.util.*;
|
|
|
import com.lc.ibps.base.core.util.Collections;
|
|
|
import com.lc.ibps.base.framework.id.UniqueIdUtil;
|
|
|
-import com.lc.ibps.base.framework.table.ICommonDao;
|
|
|
import com.lc.ibps.base.web.context.ContextUtil;
|
|
|
import com.lc.ibps.base.web.util.AppFileUtil;
|
|
|
import com.lc.ibps.business.thirtyparty.service.HumitureService;
|
|
|
@@ -19,7 +16,6 @@ import org.springframework.stereotype.Service;
|
|
|
import org.springframework.web.bind.annotation.RequestParam;
|
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
-import javax.annotation.Resource;
|
|
|
import java.io.File;
|
|
|
import java.text.SimpleDateFormat;
|
|
|
import java.util.*;
|
|
|
@@ -28,23 +24,7 @@ import static com.lc.ibps.cloud.utils.ResultUtil.setExceptionResult;
|
|
|
|
|
|
@Log4j2
|
|
|
@Service
|
|
|
-public class HumitureServiceImpl implements HumitureService {
|
|
|
-
|
|
|
- // 室内温湿度--t_snwsdjkjlb 冰箱温度--t_bxwdjkjlb 温浴箱(培养箱)温湿度--t_wyxwdjkywhjlb 阴凉柜温湿度记录---t_ylgwdjkjlb
|
|
|
- private static final String SNWSD = "t_snwsdjkjlb";
|
|
|
- private static final String BXWD = "t_bxwdjkjlb";
|
|
|
- private static final String WYXWSD = "t_wyxwdjkywhjlb";
|
|
|
- private static final String YLGWSD = "t_ylgwdjkjlb";
|
|
|
- private static final String SKJLB = "t_sshjskycljlb";
|
|
|
-
|
|
|
- private SimpleDateFormat shijian = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
- private SimpleDateFormat minute = new SimpleDateFormat("yyyy-MM-dd HH:mm");
|
|
|
- private SimpleDateFormat riqi = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
- private SimpleDateFormat shifen = new SimpleDateFormat("HH:mm");
|
|
|
- private SimpleDateFormat merge = new SimpleDateFormat("yyyyMMddHHmm");
|
|
|
-
|
|
|
- @Resource
|
|
|
- private ICommonDao<?> commonDao;
|
|
|
+public class HumitureServiceImpl extends WsdBaseServiceImpl implements HumitureService {
|
|
|
|
|
|
@Override
|
|
|
public APIResult<Void> importHumiture(@RequestParam(name = "file", required = true) MultipartFile file) {
|
|
|
@@ -290,189 +270,5 @@ public class HumitureServiceImpl implements HumitureService {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- private void addWsdData(List<Map<String, Object>> list) throws Exception {
|
|
|
- for (Map<String,Object> map : list){
|
|
|
- String deptId = BeanUtils.isEmpty(map.get("bu_men_id_"))?"":map.get("bu_men_id_").toString();
|
|
|
- String type = map.get("shu_ju_lei_xing_").toString();
|
|
|
- String leiXing = map.get("she_bei_lei_xing_").toString();
|
|
|
- Map<String,Object> data = new HashMap<>();
|
|
|
- data.put("id_", UniqueIdUtil.getId());
|
|
|
- data.put("create_time_", shijian.format(new Date()));
|
|
|
- data.put("bian_zhi_bu_men_", deptId);
|
|
|
- data.put("shi_fou_guo_shen_", "已完成");
|
|
|
- data.put("bian_zhi_ren_", "1");
|
|
|
- data.put("di_dian_", map.get("di_dian_"));
|
|
|
- data.put("bian_zhi_shi_jian", map.get("cai_ji_shi_jian_"));
|
|
|
- data.put("bu_men_", deptId);
|
|
|
- data.put("qu_yu_ming_cheng_", BeanUtils.isEmpty(map.get("qu_yu_"))?"":map.get("qu_yu_").toString());
|
|
|
- boolean add = BeanUtils.isNotEmpty(map.get("zui_xiao_zhi_")) && BeanUtils.isNotEmpty(map.get("zui_da_zhi_")) && BeanUtils.isNotEmpty(map.get("wen_shi_du_zhi_"));
|
|
|
- if (add){
|
|
|
- double humMax = 0;double humMin = 0;double hum = 0;String humStatus="";String humLimit="";
|
|
|
- if (type.equals("湿度")){
|
|
|
- humMax = Double.parseDouble(map.get("zui_da_zhi_").toString());
|
|
|
- humMin = Double.parseDouble(map.get("zui_xiao_zhi_").toString());
|
|
|
- hum = Double.parseDouble(map.get("wen_shi_du_zhi_").toString());
|
|
|
- humStatus = hum > humMax || hum < humMin ? "失控" : "正常";
|
|
|
- humLimit = humMin + "~" + humMax + "%";
|
|
|
- }
|
|
|
- double tempMax = 0;double tempMin = 0;double temp = 0;String tempStatus="";String tempLimit="";
|
|
|
- if (type.equals("温度")){
|
|
|
- tempMax = Double.parseDouble(map.get("zui_da_zhi_").toString());
|
|
|
- tempMin = Double.parseDouble(map.get("zui_xiao_zhi_").toString());
|
|
|
- temp = Double.parseDouble(map.get("wen_shi_du_zhi_").toString());
|
|
|
- tempStatus = temp > tempMax || temp < tempMin ? "失控" : "正常";
|
|
|
- tempLimit = tempMin + "~" + tempMax + "℃";
|
|
|
- }
|
|
|
- String tempPart = !tempLimit.isEmpty() ? "温度:" + tempLimit : "";
|
|
|
- String humPart = !humLimit.isEmpty() ? "湿度:" + humLimit : "";
|
|
|
- String wenDuJianKong = (tempPart.isEmpty() ? "" : tempPart) + (humPart.isEmpty() ? "" : humPart);
|
|
|
- if (leiXing.equals("冰箱")){
|
|
|
- // 冰箱 t_bxwdjkjlb
|
|
|
- addBxData(data,map,wenDuJianKong,tempStatus,tempMax,tempMin,temp);
|
|
|
- }
|
|
|
- if (leiXing.equals("环境")){
|
|
|
- // 室内温湿度 t_snwsdjkjlb
|
|
|
- addSnwsdData(data,map,wenDuJianKong,humStatus,tempStatus,tempMax,tempMin,temp,humMax,humMin,hum);
|
|
|
- }
|
|
|
- if (leiXing.equals("温浴箱")){
|
|
|
- // 温浴箱(培养箱)温湿度 t_wyxwdjkywhjlb
|
|
|
- addPyxData(data,map,wenDuJianKong,humStatus,tempStatus,tempMax,tempMin,temp,humMax,humMin,hum);
|
|
|
- }
|
|
|
- if (leiXing.equals("阴凉柜")){
|
|
|
- // 阴凉柜温湿度记录---t_ylgwdjkjlb
|
|
|
- addYlgData(data,map,wenDuJianKong,humStatus,tempStatus,tempMax,tempMin,temp,humMax,humMin,hum);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- private void addYlgData(Map<String, Object> data,Map<String, Object> map,String wenDuJianKong,String humStatus,
|
|
|
- String tempStatus,double tempMax,double tempMin,double temp,double humMax,double humMin,double hum) throws Exception {
|
|
|
- if (!exist(YLGWSD,map.get("id_").toString(),"config_id_")){
|
|
|
- data.put("yin_liang_gui_bia",map.get("cai_ji_qi_id_")+" "+map.get("cai_ji_qi_ming_ch"));
|
|
|
- data.put("fang_jian_",BeanUtils.isEmpty(map.get("fang_jian_"))?"":map.get("fang_jian_").toString());
|
|
|
- data.put("qu_yu_ming_cheng_", BeanUtils.isEmpty(map.get("qu_yu_"))?"":map.get("qu_yu_").toString());
|
|
|
- data.put("gang_wei_", BeanUtils.isEmpty(map.get("gang_wei_"))?"":map.get("gang_wei_").toString());
|
|
|
- data.put("config_id_", map.get("id_"));
|
|
|
- data.put("jian_kong_she_bei", map.get("cai_ji_qi_id_"));
|
|
|
- data.put("jian_she_bian_hao", map.get("cai_ji_qi_ming_ch"));
|
|
|
- data.put("jian_ce_shi_jian_",map.get("cai_ji_shi_jian_"));
|
|
|
- data.put("jian_ce_zhou_qi_","每日");
|
|
|
- data.put("jian_ce_ri_qi_","每天");
|
|
|
- data.put("ri_qi_lie_biao_","1,2,3,4,5,6,7");
|
|
|
- data.put("shi_ji_shi_jian_", map.get("cai_ji_shi_jian_"));
|
|
|
- data.put("wen_du_jian_kong_", wenDuJianKong);
|
|
|
- data.put("shi_kong_zhuang_t",(humStatus.equals("失控")||tempStatus.equals("失控"))?"失控":"正常");
|
|
|
-
|
|
|
- JSONArray params = new JSONArray();
|
|
|
- if (BeanUtils.isNotEmpty(temp)){
|
|
|
- params.add(setJsonList("temp",tempStatus,tempMax,tempMin,temp));
|
|
|
- }
|
|
|
- if (BeanUtils.isNotEmpty(hum)){
|
|
|
- params.add(setJsonList("hum",humStatus,humMax,humMin,hum));
|
|
|
- }
|
|
|
- data.put("lie_biao_shu_ju_",params);
|
|
|
- commonDao.execute(SqlUtil.buildInsertSql(data,YLGWSD));
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- private void addPyxData(Map<String, Object> data,Map<String, Object> map,String wenDuJianKong,String humStatus,
|
|
|
- String tempStatus,double tempMax,double tempMin,double temp,double humMax,double humMin,double hum) throws Exception {
|
|
|
- if (!exist(WYXWSD,map.get("id_").toString(),"config_id_")){
|
|
|
- data.put("she_bei_ming_chen",map.get("cai_ji_qi_ming_ch"));
|
|
|
- data.put("she_bei_bian_hao_",map.get("cai_ji_qi_id_"));
|
|
|
- data.put("fang_jian_",BeanUtils.isEmpty(map.get("fang_jian_"))?"":map.get("fang_jian_").toString());
|
|
|
- data.put("qu_yu_ming_cheng_", BeanUtils.isEmpty(map.get("qu_yu_"))?"":map.get("qu_yu_").toString());
|
|
|
- data.put("gang_wei_", BeanUtils.isEmpty(map.get("gang_wei_"))?"":map.get("gang_wei_").toString());
|
|
|
- data.put("config_id_", map.get("id_"));
|
|
|
- data.put("jian_ce_zhou_qi_","每日");
|
|
|
- data.put("ri_qi_lie_biao_","1,2,3,4,5,6,7");
|
|
|
- data.put("shi_ji_shi_jian_", map.get("cai_ji_shi_jian_"));
|
|
|
- data.put("wen_kong_zhi_fan_", wenDuJianKong);
|
|
|
- data.put("shi_kong_zhuang_t",(humStatus.equals("失控")||tempStatus.equals("失控"))?"失控":"正常");
|
|
|
-
|
|
|
- JSONArray params = new JSONArray();
|
|
|
- if (BeanUtils.isNotEmpty(temp)){
|
|
|
- params.add(setJsonList("temp",tempStatus,tempMax,tempMin,temp));
|
|
|
- }
|
|
|
- if (BeanUtils.isNotEmpty(hum)){
|
|
|
- params.add(setJsonList("hum",humStatus,humMax,humMin,hum));
|
|
|
- }
|
|
|
- data.put("lie_biao_shu_ju_",params);
|
|
|
- commonDao.execute(SqlUtil.buildInsertSql(data,WYXWSD));
|
|
|
- }
|
|
|
|
|
|
- }
|
|
|
-
|
|
|
- private void addSnwsdData(Map<String, Object> data,Map<String, Object> map,String wenDuJianKong,String humStatus,
|
|
|
- String tempStatus,double tempMax,double tempMin,double temp,double humMax,double humMin,double hum) throws Exception {
|
|
|
- if (!exist(SNWSD,map.get("id_").toString(),"wai_jian_")){
|
|
|
- data.put("fang_jian_hao_",BeanUtils.isEmpty(map.get("fang_jian_"))?"":map.get("fang_jian_").toString());
|
|
|
- data.put("qu_yu_ming_cheng_", BeanUtils.isEmpty(map.get("qu_yu_"))?"":map.get("qu_yu_").toString());
|
|
|
- data.put("gang_wei_", BeanUtils.isEmpty(map.get("gang_wei_"))?"":map.get("gang_wei_").toString());
|
|
|
- data.put("wai_jian_", map.get("id_"));
|
|
|
- data.put("jian_ce_zhou_qi_","每日");
|
|
|
- data.put("jian_ce_ri_qi_","每天");
|
|
|
- data.put("ri_qi_lie_biao_","1,2,3,4,5,6,7");
|
|
|
- data.put("shi_ji_cao_zuo_sh", map.get("cai_ji_shi_jian_"));
|
|
|
- data.put("wen_shi_du_kong_z", wenDuJianKong);
|
|
|
- data.put("shi_kong_zhuang_t",(humStatus.equals("失控")||tempStatus.equals("失控"))?"失控":"正常");
|
|
|
-
|
|
|
- JSONArray params = new JSONArray();
|
|
|
- if (BeanUtils.isNotEmpty(temp)){
|
|
|
- params.add(setJsonList("temp",tempStatus,tempMax,tempMin,temp));
|
|
|
- }
|
|
|
- if (BeanUtils.isNotEmpty(hum)){
|
|
|
- params.add(setJsonList("hum",humStatus,humMax,humMin,hum));
|
|
|
- }
|
|
|
- data.put("lie_biao_shu_ju_",params);
|
|
|
- commonDao.execute(SqlUtil.buildInsertSql(data,SNWSD));
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- private void addBxData(Map<String, Object> data,Map<String, Object> map,String wenDuJianKong,String status,double tempMax,double tempMin,double temp) throws Exception {
|
|
|
- if (!exist(BXWD,map.get("id_").toString(),"config_id_")){
|
|
|
- data.put("config_id_", map.get("id_"));
|
|
|
- data.put("bing_xiang_bian_h", map.get("cai_ji_qi_id_")+" "+map.get("cai_ji_qi_ming_ch"));
|
|
|
- data.put("wen_kong_zhi_fan_", wenDuJianKong);
|
|
|
- data.put("shi_ji_shi_jian_", minute.format(minute.parse(map.get("cai_ji_shi_jian_").toString())));
|
|
|
- data.put("yue_ri_qi_", riqi.format(minute.parse(map.get("cai_ji_shi_jian_").toString())));
|
|
|
- data.put("shi_jian_shi_fen_", shifen.format(minute.parse(map.get("cai_ji_shi_jian_").toString())));
|
|
|
- data.put("shi_kong_zhuang_t",status);
|
|
|
- data.put("fang_jian_",BeanUtils.isEmpty(map.get("fang_jian_"))?"":map.get("fang_jian_").toString());
|
|
|
- data.put("qu_yu_ming_cheng_", BeanUtils.isEmpty(map.get("qu_yu_"))?"":map.get("qu_yu_").toString());
|
|
|
- data.put("gang_wei_", BeanUtils.isEmpty(map.get("gang_wei_"))?"":map.get("gang_wei_").toString());
|
|
|
- data.put("jian_ce_zhou_qi_","每日");
|
|
|
- data.put("jian_ce_ri_qi_","每周1,2,3,4,5,6,7");
|
|
|
- data.put("ri_qi_lie_biao_","1,2,3,4,5,6,7");
|
|
|
- JSONArray params = new JSONArray();
|
|
|
- params.add(setJsonList("temp",status,tempMax,tempMin,temp));
|
|
|
- data.put("lie_biao_shu_ju_",params);
|
|
|
- commonDao.execute(SqlUtil.buildInsertSql(data,BXWD));
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- private JSONObject setJsonList(String type, String status, double max, double min, double value){
|
|
|
- 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("status",status);
|
|
|
- tempObj.put("unit",type.equals("temp")?"℃":"%");
|
|
|
- tempObj.put("label",type.equals("temp")?"温度":"湿度");
|
|
|
- tempObj.put("rate","每天");
|
|
|
- return tempObj;
|
|
|
- }
|
|
|
-
|
|
|
- public boolean exist(String tableName,String id,String field){
|
|
|
- Map<String,Object> his = commonDao.queryOne("select id_ from "+tableName+" where "+field+"='"+id+"'");
|
|
|
- if (BeanUtils.isNotEmpty(his)){
|
|
|
- return true;
|
|
|
- }
|
|
|
- return false;
|
|
|
- }
|
|
|
}
|