|
@@ -0,0 +1,762 @@
|
|
|
|
+package com.huimv.guowei.admin.group.service.impl;
|
|
|
|
+
|
|
|
|
+import cn.hutool.core.bean.BeanUtil;
|
|
|
|
+import cn.hutool.core.util.ObjectUtil;
|
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
|
+import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
|
|
|
+import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
|
+import com.baomidou.mybatisplus.core.toolkit.StringUtils;
|
|
|
|
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
|
+import com.huimv.guowei.admin.common.utils.DataUill;
|
|
|
|
+import com.huimv.guowei.admin.common.utils.Result;
|
|
|
|
+import com.huimv.guowei.admin.common.utils.ResultCode;
|
|
|
|
+import com.huimv.guowei.admin.common.utils.UploadImage;
|
|
|
|
+import com.huimv.guowei.admin.entity.*;
|
|
|
|
+import com.huimv.guowei.admin.entity.vo.BaseDuckInfoImportData;
|
|
|
|
+import com.huimv.guowei.admin.group.entity.*;
|
|
|
|
+import com.huimv.guowei.admin.group.entity.dto.ScreenProdVo;
|
|
|
|
+import com.huimv.guowei.admin.group.entity.vo.*;
|
|
|
|
+import com.huimv.guowei.admin.group.mapper.*;
|
|
|
|
+import com.huimv.guowei.admin.group.service.IGroupDuckInfoService;
|
|
|
|
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
|
+import com.huimv.guowei.admin.mapper.BaseBuildingMapper;
|
|
|
|
+import com.huimv.guowei.admin.mapper.BaseDuckBreedImgMapper;
|
|
|
|
+import com.huimv.guowei.admin.mapper.EnergyWaterMapper;
|
|
|
|
+import com.huimv.guowei.admin.utils.ExcelImportSheet;
|
|
|
|
+import com.huimv.guowei.admin.utils.Print;
|
|
|
|
+import org.apache.poi.ss.usermodel.Sheet;
|
|
|
|
+import org.apache.poi.ss.usermodel.Workbook;
|
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
|
+import org.springframework.web.multipart.MultipartFile;
|
|
|
|
+
|
|
|
|
+import javax.servlet.http.HttpServletRequest;
|
|
|
|
+import javax.servlet.http.HttpServletResponse;
|
|
|
|
+import java.io.IOException;
|
|
|
|
+import java.io.InputStream;
|
|
|
|
+import java.text.DecimalFormat;
|
|
|
|
+import java.text.ParseException;
|
|
|
|
+import java.text.SimpleDateFormat;
|
|
|
|
+import java.util.*;
|
|
|
|
+
|
|
|
|
+/**
|
|
|
|
+ * <p>
|
|
|
|
+ * 平养鸭只档案 服务实现类
|
|
|
|
+ * </p>
|
|
|
|
+ *
|
|
|
|
+ * @author author
|
|
|
|
+ * @since 2024-09-25
|
|
|
|
+ */
|
|
|
|
+@Service
|
|
|
|
+public class GroupDuckInfoServiceImpl extends ServiceImpl<GroupDuckInfoMapper, GroupDuckInfo> implements IGroupDuckInfoService {
|
|
|
|
+
|
|
|
|
+ @Autowired
|
|
|
|
+ private GroupDuckInfoMapper duckInfoMapper;
|
|
|
|
+ @Autowired
|
|
|
|
+ private UploadImage uploadImage;
|
|
|
|
+ @Autowired
|
|
|
|
+ private BaseDuckBreedImgMapper imgMapper;
|
|
|
|
+ @Autowired
|
|
|
|
+ private GroupBatchMapper batchMapper;
|
|
|
|
+ @Autowired
|
|
|
|
+ private GroupEatingMapper eatingMapper;
|
|
|
|
+ @Autowired
|
|
|
|
+ private GroupEggMapper eggMapper;
|
|
|
|
+ @Autowired
|
|
|
|
+ private BaseBuildingMapper buildingMapper;
|
|
|
|
+ @Autowired
|
|
|
|
+ private EnergyWaterMapper waterMapper;
|
|
|
|
+ @Autowired
|
|
|
|
+ private GroupLeaveMapper leaveMapper;
|
|
|
|
+ @Autowired
|
|
|
|
+ private GroupThresholdMapper thresholdMapper;
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public Result listPage(Map<String, String> paramsMap) {
|
|
|
|
+ String farmId = paramsMap.get("farmId");
|
|
|
|
+ String pageNum = paramsMap.get("pageNum");
|
|
|
|
+ String pageSize = paramsMap.get("pageSize");
|
|
|
|
+ if ("".equals(pageNum) || null == pageNum) {
|
|
|
|
+ pageNum = "1";
|
|
|
|
+ pageSize = "20";
|
|
|
|
+ }
|
|
|
|
+ String keyword = paramsMap.get("keyword");
|
|
|
|
+ String unitId = paramsMap.get("unitId");
|
|
|
|
+ Page<GroupDuckInfo> page = new Page(Integer.parseInt(pageNum), Integer.parseInt(pageSize));
|
|
|
|
+ QueryWrapper<GroupDuckInfo> queryWrapper = new QueryWrapper<>();
|
|
|
|
+ queryWrapper.eq("farm_id", farmId).eq(StringUtils.isNotBlank(unitId), "unit_id", unitId);
|
|
|
|
+ if (StringUtils.isNotBlank(keyword)) {
|
|
|
|
+ queryWrapper.and(wrapper -> wrapper.like(StringUtils.isNotBlank(keyword), "device_code", keyword)
|
|
|
|
+ .or().like(StringUtils.isNotBlank(keyword), "chi_code", keyword));
|
|
|
|
+ }
|
|
|
|
+ return new Result(ResultCode.SUCCESS, duckInfoMapper.selectPage(page, queryWrapper));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public Result addDuck(HttpServletRequest httpServletRequest, Map<String, String> paramsMap, MultipartFile imgUrl) throws ParseException, IOException {
|
|
|
|
+ String deviceCode = paramsMap.get("deviceCode");
|
|
|
|
+ String farmId = paramsMap.get("farmId");
|
|
|
|
+ GroupDuckInfo duckInfo = new GroupDuckInfo();
|
|
|
|
+ duckInfo.setFarmId(Integer.parseInt(farmId));
|
|
|
|
+ duckInfo.setDeviceCode(deviceCode);
|
|
|
|
+ QueryWrapper<GroupDuckInfo> queryWrapper = new QueryWrapper<>();
|
|
|
|
+ queryWrapper.eq("farm_id", farmId).eq("is_leave", 0);
|
|
|
|
+ if (StringUtils.isNotBlank(paramsMap.get("chiCode"))) {
|
|
|
|
+ queryWrapper.eq("device_code", deviceCode).or().eq("chi_code", paramsMap.get("chiCode"));
|
|
|
|
+ } else {
|
|
|
|
+ queryWrapper.eq("device_code", deviceCode);
|
|
|
|
+ }
|
|
|
|
+ if (duckInfoMapper.selectCount(queryWrapper) != 0) {
|
|
|
|
+ return new Result(10001, "脚环号或者翅号已存在", false);
|
|
|
|
+ }
|
|
|
|
+ if (StringUtils.isNotBlank(paramsMap.get("chiCode"))) {
|
|
|
|
+ duckInfo.setChiCode(paramsMap.get("chiCode"));
|
|
|
|
+ }
|
|
|
|
+ SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
|
+ Date date = new Date();
|
|
|
|
+ long l = date.getTime() - sdf.parse(paramsMap.get("birthDate")).getTime();
|
|
|
|
+ long l1 = l / (24 * 60 * 60 * 1000);
|
|
|
|
+ duckInfo.setDayNum((int) l1);
|
|
|
|
+ duckInfo.setBatchNum(paramsMap.get("batchNum"));
|
|
|
|
+ duckInfo.setDuckBreed(Integer.parseInt(paramsMap.get("duckBreed")));
|
|
|
|
+ duckInfo.setSex(Integer.parseInt(paramsMap.get("sex")));
|
|
|
|
+ duckInfo.setBirthDate(sdf.parse(paramsMap.get("birthDate")));
|
|
|
|
+ duckInfo.setUnitId(Integer.parseInt(paramsMap.get("unitId")));
|
|
|
|
+ duckInfo.setUnitName(paramsMap.get("unitName"));
|
|
|
|
+ duckInfo.setWeight(paramsMap.get("weight"));
|
|
|
|
+ duckInfo.setIsLeave(0);
|
|
|
|
+ if (ObjectUtil.isEmpty(imgUrl)) {
|
|
|
|
+ String duckBreed = paramsMap.get("duckBreed");
|
|
|
|
+ QueryWrapper<BaseDuckBreedImg> imgQueryWrapper = new QueryWrapper<>();
|
|
|
|
+ imgQueryWrapper.eq("duck_breed", duckBreed);
|
|
|
|
+ BaseDuckBreedImg breedImg = imgMapper.selectOne(imgQueryWrapper);
|
|
|
|
+ duckInfo.setDuckImgUrl(breedImg.getImgUrl());
|
|
|
|
+ } else {
|
|
|
|
+ String content = uploadImage.getImageCom(imgUrl);
|
|
|
|
+ duckInfo.setDuckImgUrl(content);
|
|
|
|
+ }
|
|
|
|
+ duckInfoMapper.insert(duckInfo);
|
|
|
|
+ GroupDuckInfo duckInfo1 = duckInfoMapper.selectOne(new QueryWrapper<GroupDuckInfo>().eq("device_code", deviceCode));
|
|
|
|
+ GroupBatch groupBatch = batchMapper.selectOne(new QueryWrapper<GroupBatch>().eq("batch_num", paramsMap.get("batchNum")));
|
|
|
|
+ String batchDuckId = groupBatch.getDuckId();
|
|
|
|
+ if (StringUtils.isBlank(batchDuckId)) {
|
|
|
|
+ groupBatch.setDuckId(duckInfo1.getDeviceCode());
|
|
|
|
+ } else {
|
|
|
|
+ String[] split = batchDuckId.split(",");
|
|
|
|
+ java.util.ArrayList<String> list = new java.util.ArrayList<>();
|
|
|
|
+ for (String s1 : split) {
|
|
|
|
+ if (!s1.equals(duckInfo1.getDeviceCode())) {
|
|
|
|
+ list.add(s1);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ String[] newArray = list.toArray(new String[0]);
|
|
|
|
+ String b = "";
|
|
|
|
+ for (int i = 0; i < newArray.length; i++) {
|
|
|
|
+ if (i < newArray.length - 1) {
|
|
|
|
+ b = newArray[i] + "," + b;
|
|
|
|
+ } else {
|
|
|
|
+ b = b + newArray[i];
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ groupBatch.setDuckId(b + "," + duckInfo1.getDeviceCode());
|
|
|
|
+ }
|
|
|
|
+ batchMapper.updateById(groupBatch);
|
|
|
|
+ return new Result(ResultCode.SUCCESS);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public Result editDuck(HttpServletRequest httpServletRequest, GroupDuckInfo groupDuckInfo) {
|
|
|
|
+ QueryWrapper<GroupDuckInfo> queryWrapper = new QueryWrapper<>();
|
|
|
|
+ queryWrapper.eq("farm_id", groupDuckInfo.getFarmId()).eq("is_leave", 0)
|
|
|
|
+ .ne("id", groupDuckInfo.getId()).eq("device_code", groupDuckInfo.getDeviceCode());
|
|
|
|
+ if (StringUtils.isNotBlank(groupDuckInfo.getChiCode())) {
|
|
|
|
+ queryWrapper.eq("chi_code", groupDuckInfo.getChiCode());
|
|
|
|
+ }
|
|
|
|
+ if (duckInfoMapper.selectCount(queryWrapper) != 0) {
|
|
|
|
+ return new Result(10001, "脚环号或者翅号已存在", false);
|
|
|
|
+ }
|
|
|
|
+ Date date = new Date();
|
|
|
|
+ long l = date.getTime() - groupDuckInfo.getBirthDate().getTime();
|
|
|
|
+ long l1 = l / (24 * 60 * 60 * 1000);
|
|
|
|
+ groupDuckInfo.setDayNum((int) l1);
|
|
|
|
+ duckInfoMapper.updateById(groupDuckInfo);
|
|
|
|
+ return new Result(ResultCode.SUCCESS);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public Result deleteDuck(HttpServletRequest httpServletRequest, Map<String, String> paramsMap) {
|
|
|
|
+ String id = paramsMap.get("id");
|
|
|
|
+ GroupDuckInfo duckInfo = duckInfoMapper.selectById(id);
|
|
|
|
+// if (duckInfo.getIsLeave() == 0) {
|
|
|
|
+// return new Result(10001, "暂未离场,不可删除!", false);
|
|
|
|
+// }
|
|
|
|
+ duckInfoMapper.deleteById(id);
|
|
|
|
+ String batchNum = duckInfo.getBatchNum();
|
|
|
|
+ GroupBatch batch = batchMapper.selectOne(new QueryWrapper<GroupBatch>().eq("batch_num", batchNum));
|
|
|
|
+ String duckId = batch.getDuckId();
|
|
|
|
+ String[] split = duckId.split(",");
|
|
|
|
+ java.util.ArrayList<String> list = new java.util.ArrayList<>();
|
|
|
|
+ for (String s1 : split) {
|
|
|
|
+ if (!s1.equals(duckInfo.getDeviceCode())) {
|
|
|
|
+ list.add(s1);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ String[] newArray = list.toArray(new String[0]);
|
|
|
|
+ String b = "";
|
|
|
|
+ for (int i = 0; i < newArray.length; i++) {
|
|
|
|
+ if (i < newArray.length - 1) {
|
|
|
|
+ b = newArray[i] + "," + b;
|
|
|
|
+ } else {
|
|
|
|
+ b = b + newArray[i];
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ batch.setDuckId(b);
|
|
|
|
+ batchMapper.updateById(batch);
|
|
|
|
+ return new Result(ResultCode.SUCCESS);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public Result duckDetail(HttpServletRequest httpServletRequest, Map<String, String> paramsMap) {
|
|
|
|
+ String deviceCode = paramsMap.get("deviceCode");
|
|
|
|
+ GroupDuckInfo duckInfo = duckInfoMapper.selectOne(new QueryWrapper<GroupDuckInfo>().eq("device_code", deviceCode));
|
|
|
|
+ GroupDuckInfoVo duckInfoVo = new GroupDuckInfoVo();
|
|
|
|
+ duckInfoVo.setDuckInfo(duckInfo);
|
|
|
|
+ EggAndFeedingVo feedingVo = eatingMapper.getCount(deviceCode, null);
|
|
|
|
+ duckInfoVo.setFeedingCount(feedingVo.getFeedingCount());
|
|
|
|
+ duckInfoVo.setEggCount(feedingVo.getEggCount());
|
|
|
|
+ Calendar calendar = Calendar.getInstance();
|
|
|
|
+ calendar.setTime(new Date());
|
|
|
|
+ calendar.add(Calendar.DAY_OF_MONTH, -30);
|
|
|
|
+ SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
|
+ EggAndFeedingVo feedingVo1 = eatingMapper.getCount(deviceCode, sdf.format(calendar.getTime()));
|
|
|
|
+ duckInfoVo.setFeedEgg(feedingVo1.getFeedingCount() + ":" + feedingVo1.getEggCount());
|
|
|
|
+ return new Result(ResultCode.SUCCESS, duckInfoVo);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public void updateDayAge() {
|
|
|
|
+ duckInfoMapper.updateDayAge();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public Result breedingList(Map<String, String> paramsMap) {
|
|
|
|
+ String farmId = paramsMap.get("farmId");
|
|
|
|
+ String pageNum = paramsMap.get("pageNum");
|
|
|
|
+ String pageSize = paramsMap.get("pageSize");
|
|
|
|
+ if ("".equals(pageNum) || null == pageNum) {
|
|
|
|
+ pageNum = "1";
|
|
|
|
+ pageSize = "20";
|
|
|
|
+ }
|
|
|
|
+ String deviceCode = paramsMap.get("deviceCode");
|
|
|
|
+ Date timesmorning = DataUill.getTimesmorning();
|
|
|
|
+ Date monthmorning = DataUill.getTimesMonthmorning();
|
|
|
|
+ SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
|
+ Page<BreedingVo> page = new Page<>(Integer.parseInt(pageNum), Integer.parseInt(pageSize));
|
|
|
|
+ IPage<BreedingVo> breedingVoIPage = duckInfoMapper.breedingList(farmId, sdf.format(timesmorning), sdf.format(monthmorning), page, deviceCode);
|
|
|
|
+ List<BreedingVo> records = breedingVoIPage.getRecords();
|
|
|
|
+ if (records.size() != 0) {
|
|
|
|
+ for (BreedingVo record : records) {
|
|
|
|
+ Double aDouble = Double.valueOf(record.getFeedingMonth());
|
|
|
|
+ if (record.getEggMonth() == 0) {
|
|
|
|
+ record.setFeedEgg("0");
|
|
|
|
+ } else {
|
|
|
|
+ double v = aDouble / 1000 / record.getEggMonth();
|
|
|
|
+ DecimalFormat def = new DecimalFormat("0.00");
|
|
|
|
+ record.setFeedEgg(def.format(v));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return new Result(ResultCode.SUCCESS, breedingVoIPage);
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public Result breedingDetail(Map<String, String> paramsMap) {
|
|
|
|
+ String farmId = paramsMap.get("farmId");
|
|
|
|
+ String deviceCode = paramsMap.get("deviceCode");
|
|
|
|
+ Date timesmorning = DataUill.getTimesmorning();
|
|
|
|
+ Date monthmorning = DataUill.getTimesMonthmorning();
|
|
|
|
+ SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
|
+ BreedingVo breedingVo = duckInfoMapper.breedingList1(farmId, sdf.format(timesmorning), sdf.format(monthmorning), deviceCode);
|
|
|
|
+ if (ObjectUtil.isNotEmpty(breedingVo)) {
|
|
|
|
+ Double aDouble = Double.valueOf(breedingVo.getFeedingMonth());
|
|
|
|
+ if (0 == breedingVo.getEggMonth()) {
|
|
|
|
+ breedingVo.setFeedEgg("0");
|
|
|
|
+ } else {
|
|
|
|
+ double v = aDouble / 1000 / breedingVo.getEggMonth();
|
|
|
|
+ DecimalFormat def = new DecimalFormat("0.00");
|
|
|
|
+ breedingVo.setFeedEgg(def.format(v));
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return new Result(ResultCode.SUCCESS, breedingVo);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Transactional
|
|
|
|
+ @Override
|
|
|
|
+ public Result importData(MultipartFile files) throws Exception {
|
|
|
|
+ Map<String, String> map = new HashMap<>();
|
|
|
|
+ //表头与键值对的映射关系
|
|
|
|
+ map.put("脚环号", "deviceCode");
|
|
|
|
+ map.put("翅号", "chiCode");
|
|
|
|
+ map.put("批次号", "batchNum");
|
|
|
|
+ map.put("品种", "duckBreed");
|
|
|
|
+ map.put("性别", "sex");
|
|
|
|
+ map.put("出生日期", "birthDate");
|
|
|
|
+ map.put("当前体重", "weight");
|
|
|
|
+ map.put("栋舍名称", "unitName");
|
|
|
|
+ try (
|
|
|
|
+ //这里面的对象会自动关闭
|
|
|
|
+ InputStream in = files.getInputStream();
|
|
|
|
+ Workbook workbook = ExcelImportSheet.getTypeFromExtends(in, files.getOriginalFilename())
|
|
|
|
+ ) {
|
|
|
|
+
|
|
|
|
+ //根据名称获取单张表对象 也可以使用getSheetAt(int index)获取单张表的对象 获取第一张表
|
|
|
|
+ Sheet sheet = workbook.getSheetAt(0);
|
|
|
|
+ List<ImportDuckInfoVo> list = ExcelImportSheet.getListFromExcel(sheet, ImportDuckInfoVo.class, map);
|
|
|
|
+
|
|
|
|
+ for (ImportDuckInfoVo breed : list) {
|
|
|
|
+ //底层数据库操作 insert什么的
|
|
|
|
+ QueryWrapper<BaseBuilding> buildingQueryWrapper = new QueryWrapper<>();
|
|
|
|
+ buildingQueryWrapper.eq("type", 1).eq("build_name", breed.getUnitName());
|
|
|
|
+ BaseBuilding building = buildingMapper.selectOne(buildingQueryWrapper);
|
|
|
|
+ if (ObjectUtil.isEmpty(building)) {
|
|
|
|
+ return new Result(10001, "栋舍名称不存在!", false);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ QueryWrapper<GroupDuckInfo> queryWrapper = new QueryWrapper<>();
|
|
|
|
+ queryWrapper.eq("is_leave", 0).eq("device_code", breed.getDeviceCode());
|
|
|
|
+ GroupDuckInfo duckInfo1 = duckInfoMapper.selectOne(queryWrapper);
|
|
|
|
+ if (ObjectUtil.isNotEmpty(duckInfo1)) {
|
|
|
|
+ if (StringUtils.isNotBlank(breed.getChiCode())) {
|
|
|
|
+ duckInfo1.setChiCode(breed.getChiCode());
|
|
|
|
+ }
|
|
|
|
+ duckInfo1.setUnitName(building.getBuildName());
|
|
|
|
+ duckInfo1.setUnitId(building.getId());
|
|
|
|
+ QueryWrapper<GroupBatch> batchQueryWrapper = new QueryWrapper<>();
|
|
|
|
+ batchQueryWrapper.eq("batch_num", breed.getBatchNum());
|
|
|
|
+ GroupBatch groupBatch = batchMapper.selectOne(batchQueryWrapper);
|
|
|
|
+ if (ObjectUtil.isEmpty(groupBatch)) {
|
|
|
|
+ return new Result(10001, "批次号不存在!", false);
|
|
|
|
+ }
|
|
|
|
+ duckInfo1.setBatchNum(breed.getBatchNum());
|
|
|
|
+ duckInfo1.setWeight(breed.getWeight());
|
|
|
|
+ Date date = new Date();
|
|
|
|
+ long l = date.getTime() - breed.getBirthDate().getTime();
|
|
|
|
+ long l1 = l / (24 * 60 * 60 * 1000);
|
|
|
|
+ duckInfo1.setDayNum((int) l1);
|
|
|
|
+ Date birthday = breed.getBirthDate();
|
|
|
|
+ Date date2 = new Date();
|
|
|
|
+ int result = birthday.compareTo(date2);
|
|
|
|
+ if (result > 0) {
|
|
|
|
+ return new Result(10001, "出生日期不能超过当前时间", false);
|
|
|
|
+ }
|
|
|
|
+ duckInfo1.setBirthDate(breed.getBirthDate());
|
|
|
|
+ if (StringUtils.isNotBlank(breed.getSex())) {
|
|
|
|
+ if ("雄性".equals(breed.getSex())) {
|
|
|
|
+ duckInfo1.setSex(0);
|
|
|
|
+ }
|
|
|
|
+ if ("雌性".equals(breed.getSex())) {
|
|
|
|
+ duckInfo1.setSex(1);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ QueryWrapper<BaseDuckBreedImg> queryWrapper1 = new QueryWrapper<>();
|
|
|
|
+ if ("北京鸭".equals(breed.getDuckBreed())) {
|
|
|
|
+ queryWrapper1.eq("duck_breed", 1);
|
|
|
|
+ BaseDuckBreedImg img = imgMapper.selectOne(queryWrapper1);
|
|
|
|
+ duckInfo1.setDuckBreed(1);
|
|
|
|
+ duckInfo1.setDuckImgUrl(img.getImgUrl());
|
|
|
|
+ } else if ("连城白鸭".equals(breed.getDuckBreed())) {
|
|
|
|
+ queryWrapper1.eq("duck_breed", 2);
|
|
|
|
+ BaseDuckBreedImg img = imgMapper.selectOne(queryWrapper1);
|
|
|
|
+ duckInfo1.setDuckBreed(2);
|
|
|
|
+ duckInfo1.setDuckImgUrl(img.getImgUrl());
|
|
|
|
+ } else if ("山麻鸭".equals(breed.getDuckBreed())) {
|
|
|
|
+ queryWrapper1.eq("duck_breed", 3);
|
|
|
|
+ BaseDuckBreedImg img = imgMapper.selectOne(queryWrapper1);
|
|
|
|
+ duckInfo1.setDuckBreed(3);
|
|
|
|
+ duckInfo1.setDuckImgUrl(img.getImgUrl());
|
|
|
|
+ } else if ("攸县麻鸭".equals(breed.getDuckBreed())) {
|
|
|
|
+ queryWrapper1.eq("duck_breed", 4);
|
|
|
|
+ BaseDuckBreedImg img = imgMapper.selectOne(queryWrapper1);
|
|
|
|
+ duckInfo1.setDuckBreed(4);
|
|
|
|
+ duckInfo1.setDuckImgUrl(img.getImgUrl());
|
|
|
|
+ } else if ("白改鸭".equals(breed.getDuckBreed())) {
|
|
|
|
+ queryWrapper1.eq("duck_breed", 5);
|
|
|
|
+ BaseDuckBreedImg img = imgMapper.selectOne(queryWrapper1);
|
|
|
|
+ duckInfo1.setDuckBreed(5);
|
|
|
|
+ duckInfo1.setDuckImgUrl(img.getImgUrl());
|
|
|
|
+ } else if ("缙云麻鸭".equals(breed.getDuckBreed())) {
|
|
|
|
+ queryWrapper1.eq("duck_breed", 6);
|
|
|
|
+ BaseDuckBreedImg img = imgMapper.selectOne(queryWrapper1);
|
|
|
|
+ duckInfo1.setDuckBreed(6);
|
|
|
|
+ duckInfo1.setDuckImgUrl(img.getImgUrl());
|
|
|
|
+ } else if ("绍兴鸭(带圈白翼梢)".equals(breed.getDuckBreed())) {
|
|
|
|
+ queryWrapper1.eq("duck_breed", 7);
|
|
|
|
+ BaseDuckBreedImg img = imgMapper.selectOne(queryWrapper1);
|
|
|
|
+ duckInfo1.setDuckBreed(7);
|
|
|
|
+ duckInfo1.setDuckImgUrl(img.getImgUrl());
|
|
|
|
+ } else if ("绍兴鸭(红毛绿翼梢)".equals(breed.getDuckBreed())) {
|
|
|
|
+ queryWrapper1.eq("duck_breed", 8);
|
|
|
|
+ BaseDuckBreedImg img = imgMapper.selectOne(queryWrapper1);
|
|
|
|
+ duckInfo1.setDuckBreed(8);
|
|
|
|
+ duckInfo1.setDuckImgUrl(img.getImgUrl());
|
|
|
|
+ } else if ("绍兴鸭(白羽绍鸭)".equals(breed.getDuckBreed())) {
|
|
|
|
+ queryWrapper1.eq("duck_breed", 9);
|
|
|
|
+ BaseDuckBreedImg img = imgMapper.selectOne(queryWrapper1);
|
|
|
|
+ duckInfo1.setDuckBreed(9);
|
|
|
|
+ duckInfo1.setDuckImgUrl(img.getImgUrl());
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ String batchDuckId = groupBatch.getDuckId();
|
|
|
|
+ if (StringUtils.isBlank(batchDuckId)) {
|
|
|
|
+ groupBatch.setDuckId(duckInfo1.getDeviceCode());
|
|
|
|
+ } else {
|
|
|
|
+ String[] split = batchDuckId.split(",");
|
|
|
|
+ java.util.ArrayList<String> list1 = new java.util.ArrayList<>();
|
|
|
|
+ for (String s1 : split) {
|
|
|
|
+ if (!s1.equals(duckInfo1.getDeviceCode())) {
|
|
|
|
+ list1.add(s1);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ String[] newArray = list1.toArray(new String[0]);
|
|
|
|
+ String b = "";
|
|
|
|
+ for (int i = 0; i < newArray.length; i++) {
|
|
|
|
+ if (i < newArray.length - 1) {
|
|
|
|
+ b = newArray[i] + "," + b;
|
|
|
|
+ } else {
|
|
|
|
+ b = b + newArray[i];
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ groupBatch.setDuckId(b + "," + duckInfo1.getDeviceCode());
|
|
|
|
+ }
|
|
|
|
+ batchMapper.updateById(groupBatch);
|
|
|
|
+ duckInfoMapper.updateById(duckInfo1);
|
|
|
|
+ } else {
|
|
|
|
+ GroupDuckInfo duckInfo = new GroupDuckInfo();
|
|
|
|
+ duckInfo.setDeviceCode(breed.getDeviceCode());
|
|
|
|
+ duckInfo.setIsLeave(0);
|
|
|
|
+ duckInfo.setFarmId(21);
|
|
|
|
+ if (StringUtils.isNotBlank(breed.getChiCode())) {
|
|
|
|
+ duckInfo.setChiCode(breed.getChiCode());
|
|
|
|
+ }
|
|
|
|
+ duckInfo.setUnitName(building.getBuildName());
|
|
|
|
+ duckInfo.setUnitId(building.getId());
|
|
|
|
+ QueryWrapper<GroupBatch> batchQueryWrapper = new QueryWrapper<>();
|
|
|
|
+ batchQueryWrapper.eq("batch_num", breed.getBatchNum());
|
|
|
|
+ GroupBatch groupBatch = batchMapper.selectOne(batchQueryWrapper);
|
|
|
|
+ if (ObjectUtil.isEmpty(groupBatch)) {
|
|
|
|
+ return new Result(10001, "批次号不存在!", false);
|
|
|
|
+ }
|
|
|
|
+ duckInfo.setBatchNum(breed.getBatchNum());
|
|
|
|
+ duckInfo.setWeight(breed.getWeight());
|
|
|
|
+ Date date = new Date();
|
|
|
|
+ long l = date.getTime() - breed.getBirthDate().getTime();
|
|
|
|
+ long l1 = l / (24 * 60 * 60 * 1000);
|
|
|
|
+ duckInfo.setDayNum((int) l1);
|
|
|
|
+ Date birthday = breed.getBirthDate();
|
|
|
|
+ Date date2 = new Date();
|
|
|
|
+ int result = birthday.compareTo(date2);
|
|
|
|
+ if (result > 0) {
|
|
|
|
+ return new Result(10001, "出生日期不能超过当前时间", false);
|
|
|
|
+ }
|
|
|
|
+ duckInfo.setBirthDate(breed.getBirthDate());
|
|
|
|
+ if (StringUtils.isNotBlank(breed.getSex())) {
|
|
|
|
+ if ("雄性".equals(breed.getSex())) {
|
|
|
|
+ duckInfo.setSex(0);
|
|
|
|
+ }
|
|
|
|
+ if ("雌性".equals(breed.getSex())) {
|
|
|
|
+ duckInfo.setSex(1);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ QueryWrapper<BaseDuckBreedImg> queryWrapper1 = new QueryWrapper<>();
|
|
|
|
+ if ("北京鸭".equals(breed.getDuckBreed())) {
|
|
|
|
+ queryWrapper1.eq("duck_breed", 1);
|
|
|
|
+ BaseDuckBreedImg img = imgMapper.selectOne(queryWrapper1);
|
|
|
|
+ duckInfo.setDuckBreed(1);
|
|
|
|
+ duckInfo.setDuckImgUrl(img.getImgUrl());
|
|
|
|
+ } else if ("连城白鸭".equals(breed.getDuckBreed())) {
|
|
|
|
+ queryWrapper1.eq("duck_breed", 2);
|
|
|
|
+ BaseDuckBreedImg img = imgMapper.selectOne(queryWrapper1);
|
|
|
|
+ duckInfo.setDuckBreed(2);
|
|
|
|
+ duckInfo.setDuckImgUrl(img.getImgUrl());
|
|
|
|
+ } else if ("山麻鸭".equals(breed.getDuckBreed())) {
|
|
|
|
+ queryWrapper1.eq("duck_breed", 3);
|
|
|
|
+ BaseDuckBreedImg img = imgMapper.selectOne(queryWrapper1);
|
|
|
|
+ duckInfo.setDuckBreed(3);
|
|
|
|
+ duckInfo.setDuckImgUrl(img.getImgUrl());
|
|
|
|
+ } else if ("攸县麻鸭".equals(breed.getDuckBreed())) {
|
|
|
|
+ queryWrapper1.eq("duck_breed", 4);
|
|
|
|
+ BaseDuckBreedImg img = imgMapper.selectOne(queryWrapper1);
|
|
|
|
+ duckInfo.setDuckBreed(4);
|
|
|
|
+ duckInfo.setDuckImgUrl(img.getImgUrl());
|
|
|
|
+ } else if ("白改鸭".equals(breed.getDuckBreed())) {
|
|
|
|
+ queryWrapper1.eq("duck_breed", 5);
|
|
|
|
+ BaseDuckBreedImg img = imgMapper.selectOne(queryWrapper1);
|
|
|
|
+ duckInfo.setDuckBreed(5);
|
|
|
|
+ duckInfo.setDuckImgUrl(img.getImgUrl());
|
|
|
|
+ } else if ("缙云麻鸭".equals(breed.getDuckBreed())) {
|
|
|
|
+ queryWrapper1.eq("duck_breed", 6);
|
|
|
|
+ BaseDuckBreedImg img = imgMapper.selectOne(queryWrapper1);
|
|
|
|
+ duckInfo.setDuckBreed(6);
|
|
|
|
+ duckInfo.setDuckImgUrl(img.getImgUrl());
|
|
|
|
+ } else if ("绍兴鸭(带圈白翼梢)".equals(breed.getDuckBreed())) {
|
|
|
|
+ queryWrapper1.eq("duck_breed", 7);
|
|
|
|
+ BaseDuckBreedImg img = imgMapper.selectOne(queryWrapper1);
|
|
|
|
+ duckInfo.setDuckBreed(7);
|
|
|
|
+ duckInfo.setDuckImgUrl(img.getImgUrl());
|
|
|
|
+ } else if ("绍兴鸭(红毛绿翼梢)".equals(breed.getDuckBreed())) {
|
|
|
|
+ queryWrapper1.eq("duck_breed", 8);
|
|
|
|
+ BaseDuckBreedImg img = imgMapper.selectOne(queryWrapper1);
|
|
|
|
+ duckInfo.setDuckBreed(8);
|
|
|
|
+ duckInfo.setDuckImgUrl(img.getImgUrl());
|
|
|
|
+ } else if ("绍兴鸭(白羽绍鸭)".equals(breed.getDuckBreed())) {
|
|
|
|
+ queryWrapper1.eq("duck_breed", 9);
|
|
|
|
+ BaseDuckBreedImg img = imgMapper.selectOne(queryWrapper1);
|
|
|
|
+ duckInfo.setDuckBreed(9);
|
|
|
|
+ duckInfo.setDuckImgUrl(img.getImgUrl());
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ String batchDuckId = groupBatch.getDuckId();
|
|
|
|
+ if (StringUtils.isBlank(batchDuckId)) {
|
|
|
|
+ groupBatch.setDuckId(duckInfo.getDeviceCode());
|
|
|
|
+ } else {
|
|
|
|
+ String[] split = batchDuckId.split(",");
|
|
|
|
+ java.util.ArrayList<String> list1 = new java.util.ArrayList<>();
|
|
|
|
+ for (String s1 : split) {
|
|
|
|
+ if (!s1.equals(duckInfo.getDeviceCode())) {
|
|
|
|
+ list1.add(s1);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ String[] newArray = list1.toArray(new String[0]);
|
|
|
|
+ String b = "";
|
|
|
|
+ for (int i = 0; i < newArray.length; i++) {
|
|
|
|
+ if (i < newArray.length - 1) {
|
|
|
|
+ b = newArray[i] + "," + b;
|
|
|
|
+ } else {
|
|
|
|
+ b = b + newArray[i];
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ groupBatch.setDuckId(b + "," + duckInfo.getDeviceCode());
|
|
|
|
+ }
|
|
|
|
+ batchMapper.updateById(groupBatch);
|
|
|
|
+ duckInfoMapper.insert(duckInfo);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ e.printStackTrace();
|
|
|
|
+ return new Result(10001, "数据格式异常!", false);
|
|
|
|
+ } finally {
|
|
|
|
+ //写着好看的
|
|
|
|
+ }
|
|
|
|
+ return new Result(10000, "保存成功!", true);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public void printDuckIfo(HttpServletResponse response, Map<String, String> paramsMap) throws Exception {
|
|
|
|
+ String farmId = paramsMap.get("farmId");
|
|
|
|
+ String ids = paramsMap.get("ids");
|
|
|
|
+ String[] split = ids.split(",");
|
|
|
|
+ Calendar calendar = Calendar.getInstance();
|
|
|
|
+ int year = calendar.get(Calendar.YEAR);
|
|
|
|
+ List<GroupDuckInfoOutVo> outDuckInfo = duckInfoMapper.getOutDuckInfo(year, split, farmId);
|
|
|
|
+ for (GroupDuckInfoOutVo groupDuckInfoOutVo : outDuckInfo) {
|
|
|
|
+ groupDuckInfoOutVo.setFeedCountEggCount(groupDuckInfoOutVo.getFeedingCount() + ":" + groupDuckInfoOutVo.getEggCount());
|
|
|
|
+ groupDuckInfoOutVo.setFeedEgg1(groupDuckInfoOutVo.getFeedingValue1() + ":" + groupDuckInfoOutVo.getEggValue1());
|
|
|
|
+ groupDuckInfoOutVo.setFeedEgg2(groupDuckInfoOutVo.getFeedingValue2() + ":" + groupDuckInfoOutVo.getEggValue2());
|
|
|
|
+ groupDuckInfoOutVo.setFeedEgg3(groupDuckInfoOutVo.getFeedingValue3() + ":" + groupDuckInfoOutVo.getEggValue3());
|
|
|
|
+ groupDuckInfoOutVo.setFeedEgg4(groupDuckInfoOutVo.getFeedingValue4() + ":" + groupDuckInfoOutVo.getEggValue4());
|
|
|
|
+ groupDuckInfoOutVo.setFeedEgg5(groupDuckInfoOutVo.getFeedingValue5() + ":" + groupDuckInfoOutVo.getEggValue5());
|
|
|
|
+ groupDuckInfoOutVo.setFeedEgg6(groupDuckInfoOutVo.getFeedingValue6() + ":" + groupDuckInfoOutVo.getEggValue6());
|
|
|
|
+ groupDuckInfoOutVo.setFeedEgg7(groupDuckInfoOutVo.getFeedingValue7() + ":" + groupDuckInfoOutVo.getEggValue7());
|
|
|
|
+ groupDuckInfoOutVo.setFeedEgg8(groupDuckInfoOutVo.getFeedingValue8() + ":" + groupDuckInfoOutVo.getEggValue8());
|
|
|
|
+ groupDuckInfoOutVo.setFeedEgg9(groupDuckInfoOutVo.getFeedingValue9() + ":" + groupDuckInfoOutVo.getEggValue9());
|
|
|
|
+ groupDuckInfoOutVo.setFeedEgg10(groupDuckInfoOutVo.getFeedingValue10() + ":" + groupDuckInfoOutVo.getEggValue10());
|
|
|
|
+ groupDuckInfoOutVo.setFeedEgg11(groupDuckInfoOutVo.getFeedingValue11() + ":" + groupDuckInfoOutVo.getEggValue11());
|
|
|
|
+ groupDuckInfoOutVo.setFeedEgg12(groupDuckInfoOutVo.getFeedingValue12() + ":" + groupDuckInfoOutVo.getEggValue12());
|
|
|
|
+ }
|
|
|
|
+ Print.printGroupDuckInfo(outDuckInfo);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public Result screenProd(Map<String, String> paramsMap) {
|
|
|
|
+ String farmId = paramsMap.get("farmId");
|
|
|
|
+ String unitId = paramsMap.get("unitId");
|
|
|
|
+ Date timesmorning = DataUill.getTimesmorning();
|
|
|
|
+ Integer count = duckInfoMapper.selectCount(new QueryWrapper<GroupDuckInfo>().eq("unit_id",unitId)
|
|
|
|
+ .eq("farm_id", farmId).eq("is_leave", 0));
|
|
|
|
+ List<GroupEgg> groupEggs = eggMapper.selectList(new QueryWrapper<GroupEgg>()
|
|
|
|
+ .eq("unit_id",unitId).eq("farm_id", farmId)
|
|
|
|
+ .ge("egg_date", timesmorning).groupBy("device_code"));
|
|
|
|
+ Integer eggCount = 0;
|
|
|
|
+ if (groupEggs.size() != 0) {
|
|
|
|
+ for (GroupEgg groupEgg : groupEggs) {
|
|
|
|
+ eggCount = eggCount + groupEgg.getEggCount();
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ List<GroupEating> groupEatings = eatingMapper.selectList(new QueryWrapper<GroupEating>()
|
|
|
|
+ .eq("unit_id",unitId).eq("farm_id", farmId)
|
|
|
|
+ .ge("eating_date", timesmorning));
|
|
|
|
+ Integer feedingCount = 0;
|
|
|
|
+ double feedingAvg=0.00;
|
|
|
|
+ if (groupEatings.size() != 0) {
|
|
|
|
+ for (GroupEating groupEating : groupEatings) {
|
|
|
|
+ feedingCount = feedingCount + Integer.valueOf(groupEating.getEatingValue());
|
|
|
|
+ }
|
|
|
|
+ feedingAvg = feedingCount / groupEatings.size();
|
|
|
|
+ }
|
|
|
|
+ DecimalFormat def = new DecimalFormat("0.00");
|
|
|
|
+ List<EnergyWater> waters = waterMapper.selectList(new QueryWrapper<EnergyWater>().eq("unit_id",unitId)
|
|
|
|
+ .eq("farm_id", farmId).eq("chip_code", 1006)
|
|
|
|
+ .ge("create_date", timesmorning));
|
|
|
|
+ double waterCount = 0.00;
|
|
|
|
+ double waterAvg = 0.00;
|
|
|
|
+ if (waters.size() != 0) {
|
|
|
|
+ for (EnergyWater water : waters) {
|
|
|
|
+ waterCount = waterCount + Double.valueOf(water.getWaterValue());
|
|
|
|
+ }
|
|
|
|
+ waterAvg = waterCount / waters.size();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ Integer count1 = leaveMapper.selectCount(new QueryWrapper<GroupLeave>()
|
|
|
|
+ .eq("farm_id", farmId).ge("leave_date", timesmorning));
|
|
|
|
+ ScreenProdVo screenProdVo = new ScreenProdVo();
|
|
|
|
+ screenProdVo.setDuckCount(count);
|
|
|
|
+ screenProdVo.setFeedingAvg(def.format(feedingAvg));
|
|
|
|
+ screenProdVo.setFeedingCount(feedingCount);
|
|
|
|
+ screenProdVo.setWaterAvg(def.format(waterAvg));
|
|
|
|
+ screenProdVo.setEggCount(eggCount);
|
|
|
|
+ screenProdVo.setLeaveCount(count1);
|
|
|
|
+ return new Result(ResultCode.SUCCESS, screenProdVo);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public Result listRank(Map<String, String> paramsMap) {
|
|
|
|
+ String farmId = paramsMap.get("farmId");
|
|
|
|
+ GroupThreshold groupThreshold = thresholdMapper.selectOne(new QueryWrapper<GroupThreshold>().eq("farm_id", farmId));
|
|
|
|
+ Double first = 0.00;
|
|
|
|
+ Double second = 0.00;
|
|
|
|
+ if (ObjectUtil.isNotEmpty(groupThreshold)) {
|
|
|
|
+ first = Double.valueOf(groupThreshold.getFirst());
|
|
|
|
+ second = Double.valueOf(groupThreshold.getSecond());
|
|
|
|
+ }
|
|
|
|
+ Date timesmorning = DataUill.getTimesmorning();
|
|
|
|
+ Date monthmorning = DataUill.getTimesMonthmorning();
|
|
|
|
+ SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
|
+ List<BreedingVo> breedingVos = duckInfoMapper.breedingRank(farmId, sdf.format(timesmorning), sdf.format(monthmorning));
|
|
|
|
+ if (breedingVos.size() != 0) {
|
|
|
|
+ for (BreedingVo record : breedingVos) {
|
|
|
|
+ Double aDouble = Double.valueOf(record.getFeedingMonth());
|
|
|
|
+ if (record.getEggMonth() == 0) {
|
|
|
|
+ record.setFeedEgg("0");
|
|
|
|
+ record.setType(1);
|
|
|
|
+ } else {
|
|
|
|
+ double v = aDouble / 1000 / record.getEggMonth();
|
|
|
|
+ DecimalFormat def = new DecimalFormat("0.00");
|
|
|
|
+ record.setFeedEgg(def.format(v));
|
|
|
|
+ if (v <= first) {
|
|
|
|
+ record.setType(1);
|
|
|
|
+ } else if (v <= second && v > first) {
|
|
|
|
+ record.setType(2);
|
|
|
|
+ } else {
|
|
|
|
+ record.setType(3);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ Integer firstCount = 0;
|
|
|
|
+ Integer secondCount = 0;
|
|
|
|
+ Integer threeCont = 0;
|
|
|
|
+ if (breedingVos.size() != 0) {
|
|
|
|
+ for (BreedingVo breedingVo : breedingVos) {
|
|
|
|
+ if (Double.valueOf(breedingVo.getFeedEgg()) <= first) {
|
|
|
|
+ firstCount = firstCount + 1;
|
|
|
|
+ } else if (Double.valueOf(breedingVo.getFeedEgg()) <= second && Double.valueOf(breedingVo.getFeedEgg()) > first) {
|
|
|
|
+ secondCount = secondCount + 1;
|
|
|
|
+ } else {
|
|
|
|
+ threeCont = threeCont + 1;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ JSONObject jsonObject = new JSONObject();
|
|
|
|
+ jsonObject.put("first", firstCount);
|
|
|
|
+ jsonObject.put("secondCount", secondCount);
|
|
|
|
+ jsonObject.put("threeCont", threeCont);
|
|
|
|
+ return new Result(ResultCode.SUCCESS,jsonObject);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public Result listRankList(Map<String, String> paramsMap) {
|
|
|
|
+ String farmId = paramsMap.get("farmId");
|
|
|
|
+ String type = paramsMap.get("type");
|
|
|
|
+ String deviceCode = paramsMap.get("deviceCode");
|
|
|
|
+
|
|
|
|
+ List<BreedingVo> list = new ArrayList<>();
|
|
|
|
+ Date timesmorning = DataUill.getTimesmorning();
|
|
|
|
+ Date monthmorning = DataUill.getTimesMonthmorning();
|
|
|
|
+ SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
|
+ GroupThreshold groupThreshold = thresholdMapper.selectOne(new QueryWrapper<GroupThreshold>().eq("farm_id", farmId));
|
|
|
|
+ if ("".equals(deviceCode) || null == deviceCode) {
|
|
|
|
+ Double down = 0.00;
|
|
|
|
+ Double upper = 0.00;
|
|
|
|
+ if (ObjectUtil.isNotEmpty(groupThreshold)) {
|
|
|
|
+ if ("1".equals(type)) {
|
|
|
|
+ upper = Double.valueOf(groupThreshold.getFirst());
|
|
|
|
+ } else if ("2".equals(type)) {
|
|
|
|
+ down = Double.valueOf(groupThreshold.getFirst());
|
|
|
|
+ upper = Double.valueOf(groupThreshold.getSecond());
|
|
|
|
+ } else {
|
|
|
|
+ down = Double.valueOf(groupThreshold.getSecond());
|
|
|
|
+ upper = Double.MAX_VALUE;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ List<BreedingVo> breedingVos = duckInfoMapper.breedingRank(farmId, sdf.format(timesmorning), sdf.format(monthmorning));
|
|
|
|
+ if (breedingVos.size() != 0) {
|
|
|
|
+ for (BreedingVo record : breedingVos) {
|
|
|
|
+ Double aDouble = Double.valueOf(record.getFeedingMonth());
|
|
|
|
+ if (record.getEggMonth() == 0) {
|
|
|
|
+ record.setFeedEgg("0");
|
|
|
|
+ } else {
|
|
|
|
+ double v = aDouble / 1000 / record.getEggMonth();
|
|
|
|
+ DecimalFormat def = new DecimalFormat("0.00");
|
|
|
|
+ record.setFeedEgg(def.format(v));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ for (BreedingVo breedingVo : breedingVos) {
|
|
|
|
+ if (Double.valueOf(breedingVo.getFeedEgg()) < upper && Double.valueOf(breedingVo.getFeedEgg()) >= down) {
|
|
|
|
+ breedingVo.setType(Integer.parseInt(type));
|
|
|
|
+ list.add(breedingVo);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ BreedingVo breedingVo = duckInfoMapper.breedingList1(farmId, sdf.format(timesmorning), sdf.format(monthmorning), deviceCode);
|
|
|
|
+ if (ObjectUtil.isNotEmpty(breedingVo)) {
|
|
|
|
+ Double aDouble = Double.valueOf(breedingVo.getFeedingMonth());
|
|
|
|
+ if (0 == breedingVo.getEggMonth()) {
|
|
|
|
+ breedingVo.setFeedEgg("0");
|
|
|
|
+ breedingVo.setType(1);
|
|
|
|
+ } else {
|
|
|
|
+ double v = aDouble / 1000 / breedingVo.getEggMonth();
|
|
|
|
+ DecimalFormat def = new DecimalFormat("0.00");
|
|
|
|
+ breedingVo.setFeedEgg(def.format(v));
|
|
|
|
+ if (v <= Double.valueOf(groupThreshold.getFirst())) {
|
|
|
|
+ breedingVo.setType(1);
|
|
|
|
+ } else if (v <= Double.valueOf(groupThreshold.getSecond()) && v > Double.valueOf(groupThreshold.getSecond())) {
|
|
|
|
+ breedingVo.setType(2);
|
|
|
|
+ } else {
|
|
|
|
+ breedingVo.setType(3);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ list.add(breedingVo);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return new Result(ResultCode.SUCCESS, list);
|
|
|
|
+ }
|
|
|
|
+}
|