|
@@ -1,5 +1,6 @@
|
|
|
package com.huimv.guowei.admin.service.impl;
|
|
|
|
|
|
+import cn.hutool.core.date.DateTime;
|
|
|
import cn.hutool.core.date.DateUnit;
|
|
|
import cn.hutool.core.date.DateUtil;
|
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
@@ -7,14 +8,22 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
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.entity.BaseBuilding;
|
|
|
+import com.huimv.guowei.admin.entity.BaseDuckInfo;
|
|
|
import com.huimv.guowei.admin.entity.EnergyElectricity;
|
|
|
import com.huimv.guowei.admin.entity.EnergyWater;
|
|
|
+import com.huimv.guowei.admin.entity.vo.EnergyWaterVo;
|
|
|
+import com.huimv.guowei.admin.mapper.BaseBuildingMapper;
|
|
|
+import com.huimv.guowei.admin.mapper.BaseDuckInfoMapper;
|
|
|
import com.huimv.guowei.admin.mapper.EnergyElectricityMapper;
|
|
|
import com.huimv.guowei.admin.service.IEnergyElectricityService;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
+import com.huimv.guowei.admin.utils.Print;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
+import javax.servlet.http.HttpServletResponse;
|
|
|
import javax.xml.crypto.Data;
|
|
|
import java.math.BigDecimal;
|
|
|
import java.math.RoundingMode;
|
|
@@ -35,6 +44,9 @@ import java.util.*;
|
|
|
public class EnergyElectricityServiceImpl extends ServiceImpl<EnergyElectricityMapper, EnergyElectricity> implements IEnergyElectricityService {
|
|
|
@Resource
|
|
|
private EnergyElectricityMapper energyElectricityMapper;
|
|
|
+ @Autowired
|
|
|
+ private BaseBuildingMapper buildingMapper;
|
|
|
+
|
|
|
|
|
|
@Override
|
|
|
public Result getElectricity(Map<String, String> paramsMap) {
|
|
@@ -170,4 +182,53 @@ public class EnergyElectricityServiceImpl extends ServiceImpl<EnergyElectricityM
|
|
|
}
|
|
|
return new Result(ResultCode.SUCCESS,energyElectricityList);
|
|
|
}
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void printElectricity(HttpServletResponse response, Map<String, String> paramsMap) throws Exception {
|
|
|
+ String farmId = paramsMap.get("farmId");
|
|
|
+ String type = paramsMap.get("type");//选择要导出的类型
|
|
|
+ String startTime = paramsMap.get("startTime");
|
|
|
+ String endTime = paramsMap.get("endTime");
|
|
|
+
|
|
|
+ List<EnergyWaterVo> waterVos = new ArrayList<>();
|
|
|
+ //今日
|
|
|
+ QueryWrapper<EnergyElectricity> queryWrapper = new QueryWrapper<>();
|
|
|
+ queryWrapper.eq("farm_id", farmId);
|
|
|
+ if (type.equals("1")) {
|
|
|
+ Date timesmorning = DataUill.getTimesmorning();
|
|
|
+ queryWrapper.ge("create_date", timesmorning);
|
|
|
+ waterVos = energyElectricityMapper.printElectricity(queryWrapper);
|
|
|
+ }
|
|
|
+ //本周
|
|
|
+
|
|
|
+ if (type.equals("2")) {
|
|
|
+ DateTime dateTime = DateUtil.beginOfWeek(new Date());
|
|
|
+ queryWrapper.ge("create_date", dateTime);
|
|
|
+ waterVos = energyElectricityMapper.printElectricity(queryWrapper);
|
|
|
+ }
|
|
|
+ //本月
|
|
|
+
|
|
|
+ if (type.equals("3")) {
|
|
|
+ Date timesMonthmorning = DataUill.getTimesMonthmorning();
|
|
|
+ queryWrapper.ge("create_date", timesMonthmorning);
|
|
|
+ waterVos = energyElectricityMapper.printElectricity(queryWrapper);
|
|
|
+ }
|
|
|
+ //自定义
|
|
|
+
|
|
|
+ if (type.equals("4")) {
|
|
|
+ endTime = endTime + " 23:59:59";
|
|
|
+ queryWrapper.between("create_date", startTime, endTime);
|
|
|
+ waterVos = energyElectricityMapper.printElectricity(queryWrapper);
|
|
|
+ }
|
|
|
+ List<EnergyWaterVo> waterVoList = new ArrayList<>();
|
|
|
+ for (EnergyWaterVo waterVo : waterVos) {
|
|
|
+ EnergyWaterVo waterVo1 = new EnergyWaterVo();
|
|
|
+ BaseBuilding baseBuilding = buildingMapper.selectById(waterVo.getUnitId());
|
|
|
+ waterVo1.setWaterValue(waterVo.getWaterValue());
|
|
|
+ waterVo1.setChipName(baseBuilding.getBuildName());
|
|
|
+ waterVo1.setCreateDate(waterVo.getCreateDate());
|
|
|
+ waterVoList.add(waterVo1);
|
|
|
+ }
|
|
|
+ Print.printElectricity(waterVoList);
|
|
|
+ }
|
|
|
}
|