|
@@ -0,0 +1,51 @@
|
|
|
|
+package com.huimv.farm.musk.health.service.impl;
|
|
|
|
+
|
|
|
|
+import cn.hutool.core.bean.BeanUtil;
|
|
|
|
+import cn.hutool.core.util.ObjectUtil;
|
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
|
+import com.huimv.farm.musk.common.utils.Result;
|
|
|
|
+import com.huimv.farm.musk.common.utils.ResultCode;
|
|
|
|
+import com.huimv.farm.musk.health.entity.HealthThreshold;
|
|
|
|
+import com.huimv.farm.musk.health.mapper.HealthThresholdMapper;
|
|
|
|
+import com.huimv.farm.musk.health.service.IHealthThresholdService;
|
|
|
|
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
|
+
|
|
|
|
+import java.util.Map;
|
|
|
|
+
|
|
|
|
+/**
|
|
|
|
+ * <p>
|
|
|
|
+ * 健康阈值设置 服务实现类
|
|
|
|
+ * </p>
|
|
|
|
+ *
|
|
|
|
+ * @author author
|
|
|
|
+ * @since 2024-09-03
|
|
|
|
+ */
|
|
|
|
+@Service
|
|
|
|
+public class HealthThresholdServiceImpl extends ServiceImpl<HealthThresholdMapper, HealthThreshold> implements IHealthThresholdService {
|
|
|
|
+
|
|
|
|
+ @Autowired
|
|
|
|
+ private HealthThresholdMapper thresholdMapper;
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public Result listThreshold(Map<String, String> paramsMap) {
|
|
|
|
+ String farmId = paramsMap.get("farmId");
|
|
|
|
+ HealthThreshold threshold = thresholdMapper.selectOne(new QueryWrapper<HealthThreshold>().eq("farm_id", farmId));
|
|
|
|
+ return new Result(ResultCode.SUCCESS, threshold);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public Result addOrEdit(HealthThreshold healthThreshold) {
|
|
|
|
+ Integer farmId = healthThreshold.getFarmId();
|
|
|
|
+ HealthThreshold threshold = thresholdMapper.selectOne(new QueryWrapper<HealthThreshold>().eq("farm_id", farmId));
|
|
|
|
+ if (ObjectUtil.isNotEmpty(threshold)) {
|
|
|
|
+ BeanUtil.copyProperties(healthThreshold, threshold);
|
|
|
|
+ thresholdMapper.updateById(threshold);
|
|
|
|
+ return new Result(10000, "修改成功", true);
|
|
|
|
+ } else {
|
|
|
|
+ thresholdMapper.insert(healthThreshold);
|
|
|
|
+ return new Result(10000, "添加成功", true);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+}
|