|
@@ -5,12 +5,14 @@ import com.kuyuntech.vrv.coreapi.service.core.DeviceParamService;
|
|
|
import com.kuyuntech.vrv.coreservice.dao.core.DeviceParamDao;
|
|
|
import com.kuyuntech.vrv.coreservice.domain.core.DeviceParam;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
-import org.hibernate.criterion.MatchMode;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
import com.kuyuntech.vrv.coreapi.bean.core.DeviceParamBean;
|
|
|
import com.wbspool.fastboot.core.common.bean.PagerBean;
|
|
|
|
|
|
+import java.text.ParseException;
|
|
|
+import java.text.SimpleDateFormat;
|
|
|
+import java.util.Date;
|
|
|
import java.util.List;
|
|
|
|
|
|
import org.slf4j.Logger;
|
|
@@ -100,6 +102,7 @@ public class DeviceParamServiceImpl extends AbstractFastbootService<DeviceParam,
|
|
|
return deviceParamBean;
|
|
|
}
|
|
|
|
|
|
+
|
|
|
@Override
|
|
|
public DeviceParamBean delete(DeviceParamBean deviceParamBean) {
|
|
|
|
|
@@ -142,6 +145,143 @@ public class DeviceParamServiceImpl extends AbstractFastbootService<DeviceParam,
|
|
|
return deviceParamBean;
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public DeviceParamBean findTimeData(DeviceParamBean deviceParamBean) {
|
|
|
+ if (deviceParamBean == null) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ DeviceParam deviceParam = deviceParamDao.findByIdAndValid(deviceParamBean.getId(), VALID);
|
|
|
+
|
|
|
+ //获取数据时间
|
|
|
+ Date createTime = deviceParam.getCreateTime();
|
|
|
+ String creatTimeStr = createTime.toString();
|
|
|
+ String substring = creatTimeStr.substring(11, 13);
|
|
|
+
|
|
|
+ //获取当前时间
|
|
|
+ Date currentTime = new Date();
|
|
|
+ SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");//定义新的日期格式
|
|
|
+ //format():将给定的 Date 格式化为日期/时间字符串。即:date--->String
|
|
|
+ String dateString = formatter.format(currentTime);
|
|
|
+ try {
|
|
|
+ Date updateTime = formatter.parse(dateString);//parse():String--->date
|
|
|
+ } catch (ParseException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+
|
|
|
+ String nowSrtSub = dateString.substring(11, 13);
|
|
|
+
|
|
|
+// System.out.println(creatTimeStr);
|
|
|
+// System.out.println(substring);
|
|
|
+// System.out.println("-----------------------------------");
|
|
|
+// System.out.println(dateString);
|
|
|
+// System.out.println(nowSrtSub);
|
|
|
+
|
|
|
+ if (substring.equals(nowSrtSub)) {
|
|
|
+
|
|
|
+ System.out.println("当前数据与当前时间相等!");
|
|
|
+
|
|
|
+ //更新温度数据
|
|
|
+ Long Id = deviceParamBean.getId();
|
|
|
+
|
|
|
+ if (Id <= 334) {
|
|
|
+ //新建一个bean用来查询温度实际
|
|
|
+ DeviceParam deviceParamData = new DeviceParam();
|
|
|
+ deviceParamData.setId(292L);
|
|
|
+
|
|
|
+ DeviceParam WD_SJData = deviceParamDao.findByIdAndValid(deviceParamData.getId(), VALID);
|
|
|
+
|
|
|
+ String value = WD_SJData.getValue();
|
|
|
+
|
|
|
+ //将温度实际的数据保存到对应的时间
|
|
|
+ deviceParam.setValue(value);
|
|
|
+
|
|
|
+ if (deviceParam == null) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+ deviceParamDao.save(deviceParam);
|
|
|
+
|
|
|
+ domainToBean(deviceParam, deviceParamBean, "id", "code", "version", "createTime", "updateTime", "valid", "deviceId");
|
|
|
+ }
|
|
|
+
|
|
|
+ if (Id > 334 && Id <= 358) {
|
|
|
+ //更新湿度数据
|
|
|
+ //新建一个bean用来查询温度实际
|
|
|
+ DeviceParam deviceParamData = new DeviceParam();
|
|
|
+ deviceParamData.setId(280L);
|
|
|
+
|
|
|
+ DeviceParam SD_SJData = deviceParamDao.findByIdAndValid(deviceParamData.getId(), VALID);
|
|
|
+
|
|
|
+ String value = SD_SJData.getValue();
|
|
|
+
|
|
|
+ //将温度实际的数据保存到对应的时间
|
|
|
+ deviceParam.setValue(value);
|
|
|
+
|
|
|
+ if (deviceParam == null) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+ deviceParamDao.save(deviceParam);
|
|
|
+
|
|
|
+ domainToBean(deviceParam, deviceParamBean, "id", "code", "version", "createTime", "updateTime", "valid", "deviceId");
|
|
|
+ }
|
|
|
+
|
|
|
+ if (Id > 358 && Id <= 382) {
|
|
|
+ //更新温度设定数据
|
|
|
+ //新建一个bean用来查询温度实际
|
|
|
+ DeviceParam deviceParamData = new DeviceParam();
|
|
|
+ deviceParamData.setId(296L);
|
|
|
+
|
|
|
+ DeviceParam SD_SJData = deviceParamDao.findByIdAndValid(deviceParamData.getId(), VALID);
|
|
|
+
|
|
|
+ String value = SD_SJData.getValue();
|
|
|
+
|
|
|
+ //将温度实际的数据保存到对应的时间
|
|
|
+ deviceParam.setValue(value);
|
|
|
+
|
|
|
+ if (deviceParam == null) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+ deviceParamDao.save(deviceParam);
|
|
|
+
|
|
|
+ domainToBean(deviceParam, deviceParamBean, "id", "code", "version", "createTime", "updateTime", "valid", "deviceId");
|
|
|
+ }
|
|
|
+
|
|
|
+ if (Id > 382 && Id <= 407) {
|
|
|
+ //更新湿度设定数据
|
|
|
+ //新建一个bean用来查询温度实际
|
|
|
+ DeviceParam deviceParamData = new DeviceParam();
|
|
|
+ deviceParamData.setId(231L);
|
|
|
+
|
|
|
+ DeviceParam SD_SJData = deviceParamDao.findByIdAndValid(deviceParamData.getId(), VALID);
|
|
|
+
|
|
|
+ String value = SD_SJData.getValue();
|
|
|
+
|
|
|
+ //将温度实际的数据保存到对应的时间
|
|
|
+ deviceParam.setValue(value);
|
|
|
+
|
|
|
+ if (deviceParam == null) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+ deviceParamDao.save(deviceParam);
|
|
|
+
|
|
|
+ domainToBean(deviceParam, deviceParamBean, "id", "code", "version", "createTime", "updateTime", "valid", "deviceId");
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ if (deviceParam == null) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ BeanUtils.copyProperties(deviceParam, deviceParamBean);
|
|
|
+ return deviceParamBean;
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
public DeviceParamBean find(String code) {
|
|
|
return this.find(DeviceParamBean.builder().code(code).build());
|