|
@@ -1,11 +1,31 @@
|
|
|
package com.huimv.eartag2.manage2.service.impl;
|
|
|
|
|
|
+import cn.hutool.core.bean.BeanUtil;
|
|
|
+import cn.hutool.core.util.ObjectUtil;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
+import com.baomidou.mybatisplus.core.toolkit.StringUtils;
|
|
|
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
+import com.huimv.eartag2.common.utils.Result;
|
|
|
+import com.huimv.eartag2.common.utils.ResultCode;
|
|
|
+import com.huimv.eartag2.manage2.mapper.EartagDataMapper;
|
|
|
+import com.huimv.eartag2.manage2.mapper.EartagDeviceRegisterMapper;
|
|
|
+import com.huimv.eartag2.manage2.pojo.EartagData;
|
|
|
+import com.huimv.eartag2.manage2.pojo.EartagDeviceRegister;
|
|
|
import com.huimv.eartag2.manage2.pojo.EartagEartagRegister;
|
|
|
import com.huimv.eartag2.manage2.mapper.EartagEartagRegisterMapper;
|
|
|
+import com.huimv.eartag2.manage2.pojo.pojovo.EartagEartagRegisterVo;
|
|
|
import com.huimv.eartag2.manage2.service.IEartagEartagRegisterService;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
+import com.huimv.eartag2.manage2.vo.EartagDeviceRegisterVo;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.scheduling.annotation.Async;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.HashMap;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+
|
|
|
/**
|
|
|
* <p>
|
|
|
* 服务实现类
|
|
@@ -17,4 +37,69 @@ import org.springframework.stereotype.Service;
|
|
|
@Service
|
|
|
public class EartagEartagRegisterServiceImpl extends ServiceImpl<EartagEartagRegisterMapper, EartagEartagRegister> implements IEartagEartagRegisterService {
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private EartagDeviceRegisterMapper eartagDeviceRegisterMapper;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private EartagDataMapper eartagDataMapper;
|
|
|
+
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Result listFarmUnitEartagData(Map<String, String> params) {
|
|
|
+ String pageSize = params.get("pageSize");
|
|
|
+ String pageNo = params.get("pageNo");
|
|
|
+ String unitId = params.get("unitId");
|
|
|
+ String deviceCode = params.get("deviceCode");
|
|
|
+ String farmId = params.get("farmId");
|
|
|
+ if (StringUtils.isBlank(pageNo)){
|
|
|
+ pageNo="1";
|
|
|
+ }
|
|
|
+ if (StringUtils.isBlank(pageSize)){
|
|
|
+ pageSize="20";
|
|
|
+ }
|
|
|
+ QueryWrapper<EartagEartagRegister> wrapper = new QueryWrapper<>();
|
|
|
+ //设备
|
|
|
+ wrapper.like(StringUtils.isNotBlank(deviceCode),"belong_device",deviceCode);
|
|
|
+ wrapper.eq("farm_id",farmId);
|
|
|
+ wrapper.eq(StringUtils.isNotBlank(unitId),"unit_id",unitId);
|
|
|
+ Page<EartagEartagRegister> page = this.page(new Page<>(Long.parseLong(pageNo), Long.parseLong(pageSize)), wrapper);
|
|
|
+
|
|
|
+
|
|
|
+ Page<EartagEartagRegisterVo> eartagDeviceRegisterVoPage = new Page<>();
|
|
|
+ List<EartagEartagRegisterVo> listVo = new ArrayList();
|
|
|
+ BeanUtil.copyProperties(page,eartagDeviceRegisterVoPage);
|
|
|
+
|
|
|
+ Float maxEarTemp = 0F;
|
|
|
+ Float minEarTemp = 0F;
|
|
|
+ for (EartagEartagRegister record : page.getRecords()) {
|
|
|
+ EartagEartagRegisterVo eartagDeviceRegisterVo = new EartagEartagRegisterVo();
|
|
|
+ BeanUtil.copyProperties(record,eartagDeviceRegisterVo);
|
|
|
+
|
|
|
+ EartagData eartagData = eartagDataMapper.selectOne(new QueryWrapper<EartagData>().eq("earmark", record.getEarmark()).orderByDesc("id").last("limit 1"));
|
|
|
+ eartagDeviceRegisterVo.setAct(eartagData.getAct1());
|
|
|
+ Float earTemp1 = eartagData.getEarTemp1();
|
|
|
+ eartagDeviceRegisterVo.setEarTemp(earTemp1);
|
|
|
+ eartagDeviceRegisterVo.setEnvTemp(eartagData.getEnvTemp1());
|
|
|
+ eartagDeviceRegisterVo.setSignal(eartagData.getSignal1());
|
|
|
+
|
|
|
+ maxEarTemp = Math.max(earTemp1,maxEarTemp);
|
|
|
+ minEarTemp = Math.min(earTemp1,minEarTemp);
|
|
|
+ listVo.add(eartagDeviceRegisterVo);
|
|
|
+ }
|
|
|
+ Map map = new HashMap();
|
|
|
+ long allCount = this.count(wrapper);
|
|
|
+ //在线
|
|
|
+ wrapper.eq("active_status", 1);
|
|
|
+ long onCount = this.count(wrapper);
|
|
|
+
|
|
|
+ map.put("countOff",allCount-onCount);
|
|
|
+
|
|
|
+ map.put("countOn",onCount);
|
|
|
+ map.put("countAll",allCount);
|
|
|
+ map.put("maxEarTemp",maxEarTemp);
|
|
|
+ map.put("minEarTemp",minEarTemp);
|
|
|
+ map.put("page",page);
|
|
|
+
|
|
|
+ return new Result(ResultCode.SUCCESS,map);
|
|
|
+ }
|
|
|
}
|