|
@@ -1,15 +1,17 @@
|
|
|
package com.huimv.receiver.eco.controller;
|
|
|
|
|
|
+import cn.hutool.core.util.ObjectUtil;
|
|
|
import com.huimv.receiver.cloud.service.IWarningInfo;
|
|
|
-import com.huimv.receiver.eco.entity.HumAndTemDto;
|
|
|
-import com.huimv.receiver.eco.service.ISysHumidityService;
|
|
|
-import com.huimv.receiver.eco.service.ISysTemperatureService;
|
|
|
+import com.huimv.receiver.eco.entity.*;
|
|
|
+import com.huimv.receiver.eco.service.*;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.web.bind.annotation.PostMapping;
|
|
|
import org.springframework.web.bind.annotation.RequestBody;
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
|
|
|
//接收温湿度数据
|
|
|
@RestController
|
|
@@ -21,25 +23,104 @@ public class EcoController {
|
|
|
@Autowired
|
|
|
private ISysTemperatureService sysTemperatureService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private IBaseWarningInfoService baseWarningInfoService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private ISysFodderService fodderService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private ISysMonthWaterService monthWaterService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private ISysDayWaterService dayWaterService;
|
|
|
|
|
|
|
|
|
|
|
|
@PostMapping(value = "/save")
|
|
|
public String save(@RequestBody HumAndTemDto humAndTemDto){
|
|
|
System.out.println("开始");
|
|
|
- try {
|
|
|
- sysHumidityService.save(humAndTemDto.getHumidity());
|
|
|
- }catch (Exception e){
|
|
|
- System.out.println("湿度存储失败");
|
|
|
+
|
|
|
+ if (ObjectUtil.isEmpty(humAndTemDto)){
|
|
|
+ return "数据为空";
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ List<SysHumidity> humidity = humAndTemDto.getHumidity();
|
|
|
+ if (ObjectUtil.isNotEmpty(humidity)){
|
|
|
+ try {
|
|
|
+ sysHumidityService.saveBatch(humidity);
|
|
|
+ }catch (Exception e){
|
|
|
+ System.out.println("湿度存储失败");
|
|
|
+ }
|
|
|
+ }else {
|
|
|
+ System.out.println("湿度数据为空");
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ List<SysTemperature> temperature = humAndTemDto.getTemperature();
|
|
|
+ if (ObjectUtil.isNotEmpty(temperature)){
|
|
|
+ try {
|
|
|
+ sysTemperatureService.saveBatch(temperature);
|
|
|
+ }catch (Exception e){
|
|
|
+ System.out.println("温度存储失败");
|
|
|
+ }
|
|
|
+
|
|
|
+ }else {
|
|
|
+ System.out.println("温度数据为空");
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ List<BaseWarningInfo> warningInfos = humAndTemDto.getWarningInfos();
|
|
|
+ if (ObjectUtil.isNotEmpty(warningInfos)){
|
|
|
+ try {
|
|
|
+ baseWarningInfoService.saveBatch(warningInfos);
|
|
|
+ }catch (Exception e){
|
|
|
+ System.out.println("报警存储失败");
|
|
|
+ }
|
|
|
+
|
|
|
+ }else {
|
|
|
+ System.out.println("报警数据为空");
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ List<SysFodder> fodders = humAndTemDto.getFodders();
|
|
|
+ if (ObjectUtil.isNotEmpty(fodders)){
|
|
|
+ try {
|
|
|
+ fodderService.saveBatch(fodders);
|
|
|
+ }catch (Exception e){
|
|
|
+ System.out.println("用料存储失败");
|
|
|
+ }
|
|
|
+
|
|
|
+ }else {
|
|
|
+ System.out.println("用料数据为空");
|
|
|
}
|
|
|
|
|
|
- try {
|
|
|
- sysTemperatureService.save(humAndTemDto.getTemperature());
|
|
|
- }catch (Exception e){
|
|
|
- System.out.println("温度存储失败");
|
|
|
+
|
|
|
+ List<SysMonthWater> monthWaters = humAndTemDto.getMonthWaters();
|
|
|
+ if (ObjectUtil.isNotEmpty(monthWaters)){
|
|
|
+ try {
|
|
|
+ monthWaterService.saveBatch(monthWaters);
|
|
|
+ }catch (Exception e){
|
|
|
+ System.out.println("月用水存储失败");
|
|
|
+ }
|
|
|
+
|
|
|
+ }else {
|
|
|
+ System.out.println("月用水数据为空");
|
|
|
}
|
|
|
|
|
|
|
|
|
+ List<SysDayWater> dayWaters = humAndTemDto.getDayWaters();
|
|
|
+ if (ObjectUtil.isNotEmpty(dayWaters)){
|
|
|
+ try {
|
|
|
+ dayWaterService.saveBatch(dayWaters);
|
|
|
+ }catch (Exception e){
|
|
|
+ System.out.println("日用水存储失败");
|
|
|
+ }
|
|
|
+ }else {
|
|
|
+ System.out.println("日用水数据为空");
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
|
|
|
System.out.println("结束");
|