|
@@ -1,16 +1,22 @@
|
|
package vip.xiaonuo.production.service.impl;
|
|
package vip.xiaonuo.production.service.impl;
|
|
|
|
|
|
import cn.hutool.core.date.DateUtil;
|
|
import cn.hutool.core.date.DateUtil;
|
|
|
|
+import cn.hutool.core.util.ObjectUtil;
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
|
|
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import vip.xiaonuo.production.entity.ProductionEnergy;
|
|
import vip.xiaonuo.production.entity.ProductionEnergy;
|
|
|
|
+import vip.xiaonuo.production.entity.ProductionEnergyPrice;
|
|
|
|
+import vip.xiaonuo.production.entity.vo.ProductionWriteEnergyVo;
|
|
import vip.xiaonuo.production.mapper.ProductionEnergyMapper;
|
|
import vip.xiaonuo.production.mapper.ProductionEnergyMapper;
|
|
|
|
+import vip.xiaonuo.production.mapper.ProductionEnergyPriceMapper;
|
|
|
|
+import vip.xiaonuo.production.mapper.ProductionWriteEnergyMapper;
|
|
import vip.xiaonuo.production.param.ProductionEnergyParam;
|
|
import vip.xiaonuo.production.param.ProductionEnergyParam;
|
|
import vip.xiaonuo.production.service.IProductionEnergyService;
|
|
import vip.xiaonuo.production.service.IProductionEnergyService;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
|
|
+import java.util.ArrayList;
|
|
import java.util.Date;
|
|
import java.util.Date;
|
|
import java.util.List;
|
|
import java.util.List;
|
|
|
|
|
|
@@ -28,23 +34,158 @@ public class ProductionEnergyServiceImpl extends ServiceImpl<ProductionEnergyMap
|
|
@Autowired
|
|
@Autowired
|
|
private ProductionEnergyMapper energyMapper;
|
|
private ProductionEnergyMapper energyMapper;
|
|
|
|
|
|
|
|
+// @Override
|
|
|
|
+// public List<ProductionEnergy> getList(ProductionEnergyParam energyParam) {
|
|
|
|
+// String orgId = energyParam.getOrgId();
|
|
|
|
+// Integer timeType = energyParam.getTimeType();
|
|
|
|
+// String locationName = energyParam.getLocationName();
|
|
|
|
+// QueryWrapper<ProductionEnergy> queryWrapper = new QueryWrapper<>();
|
|
|
|
+// queryWrapper.eq(StringUtils.isNotBlank(orgId), "org_id", orgId)
|
|
|
|
+// .eq(StringUtils.isNotBlank(locationName), "location_name", locationName);
|
|
|
|
+// queryWrapper.select(" IFNULL(sum(water),'0') water,IFNULL(sum(electricity),'0') electricity,IFNULL(sum(gas),'0') gas,create_time createTime");
|
|
|
|
+// if (0 == timeType) {
|
|
|
|
+// queryWrapper.groupBy("DATE_FORMAT(create_time,'%Y')");
|
|
|
|
+// } else {
|
|
|
|
+// queryWrapper.ge("create_time", DateUtil.beginOfYear(new Date()));
|
|
|
|
+// queryWrapper.groupBy("DATE_FORMAT(create_time,'%Y-%m')");
|
|
|
|
+// }
|
|
|
|
+// queryWrapper.orderByAsc("create_time");
|
|
|
|
+// return energyMapper.selectList(queryWrapper);
|
|
|
|
+// }
|
|
|
|
+
|
|
|
|
+ @Autowired
|
|
|
|
+ private ProductionEnergyPriceMapper priceMapper;
|
|
|
|
+ @Autowired
|
|
|
|
+ private ProductionWriteEnergyMapper writeEnergyMapper;
|
|
@Override
|
|
@Override
|
|
- public List<ProductionEnergy> getList(ProductionEnergyParam energyParam) {
|
|
|
|
|
|
+ public List<ProductionWriteEnergyVo> getList(ProductionEnergyParam energyParam) {
|
|
String orgId = energyParam.getOrgId();
|
|
String orgId = energyParam.getOrgId();
|
|
Integer timeType = energyParam.getTimeType();
|
|
Integer timeType = energyParam.getTimeType();
|
|
- String locationName = energyParam.getLocationName();
|
|
|
|
- QueryWrapper<ProductionEnergy> queryWrapper = new QueryWrapper<>();
|
|
|
|
- queryWrapper.eq(StringUtils.isNotBlank(orgId), "org_id", orgId)
|
|
|
|
- .eq(StringUtils.isNotBlank(locationName), "location_name", locationName);
|
|
|
|
- queryWrapper.select(" IFNULL(sum(water),'0') water,IFNULL(sum(electricity),'0') electricity,IFNULL(sum(gas),'0') gas,create_time createTime");
|
|
|
|
- if (0 == timeType) {
|
|
|
|
- queryWrapper.groupBy("DATE_FORMAT(create_time,'%Y')");
|
|
|
|
- } else {
|
|
|
|
- queryWrapper.ge("create_time", DateUtil.beginOfYear(new Date()));
|
|
|
|
- queryWrapper.groupBy("DATE_FORMAT(create_time,'%Y-%m')");
|
|
|
|
|
|
+ if (ObjectUtil.isEmpty(timeType) ){
|
|
|
|
+ timeType = 0;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ QueryWrapper<ProductionEnergyPrice> priceQueryWrapper = new QueryWrapper<>();
|
|
|
|
+ priceQueryWrapper.eq(StringUtils.isNotBlank(orgId),"org_id",orgId);
|
|
|
|
+ List<ProductionEnergyPrice> energyPrice = priceMapper.selectList(priceQueryWrapper);
|
|
|
|
+
|
|
|
|
+ ProductionEnergyPrice productionEnergyPrice = null;
|
|
|
|
+ if (ObjectUtil.isEmpty(energyPrice)){
|
|
|
|
+ productionEnergyPrice =new ProductionEnergyPrice();
|
|
|
|
+ productionEnergyPrice.setElectricity("1");
|
|
|
|
+
|
|
|
|
+ productionEnergyPrice.setZhengQi("1");
|
|
|
|
+
|
|
|
|
+ productionEnergyPrice.setDanQi("1");
|
|
|
|
+
|
|
|
|
+ productionEnergyPrice.setYaSuo("1");
|
|
|
|
+
|
|
|
|
+ productionEnergyPrice.setRoWater("1");
|
|
|
|
+
|
|
|
|
+ productionEnergyPrice.setZlWater("1");
|
|
|
|
+
|
|
|
|
+ productionEnergyPrice.setXhWater("1");
|
|
|
|
+
|
|
|
|
+ productionEnergyPrice.setQdWater("1");
|
|
|
|
+
|
|
|
|
+ productionEnergyPrice.setSwdWater("1");
|
|
|
|
+
|
|
|
|
+ productionEnergyPrice.setEswdWater("1");
|
|
|
|
+
|
|
|
|
+ productionEnergyPrice.setReWater("1");
|
|
|
|
+
|
|
|
|
+ productionEnergyPrice.setDiwenWater("1");
|
|
|
|
+
|
|
|
|
+ productionEnergyPrice.setFuSwdYierchun("1");
|
|
|
|
+
|
|
|
|
+ productionEnergyPrice.setFuEswdYierchun("1");
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ if (ObjectUtil.isNotEmpty(energyPrice)) {
|
|
|
|
+ productionEnergyPrice = energyPrice.get(0);
|
|
|
|
+ if ("".equals(productionEnergyPrice.getElectricity())) {
|
|
|
|
+ productionEnergyPrice.setElectricity("1");
|
|
|
|
+ }
|
|
|
|
+ if ("".equals(productionEnergyPrice.getZhengQi())) {
|
|
|
|
+ productionEnergyPrice.setZhengQi("1");
|
|
|
|
+ }
|
|
|
|
+ if ("".equals(productionEnergyPrice.getDanQi())) {
|
|
|
|
+ productionEnergyPrice.setDanQi("1");
|
|
|
|
+ }
|
|
|
|
+ if ("".equals(productionEnergyPrice.getYaSuo())) {
|
|
|
|
+ productionEnergyPrice.setYaSuo("1");
|
|
|
|
+ }
|
|
|
|
+ if ("".equals(productionEnergyPrice.getRoWater())) {
|
|
|
|
+ productionEnergyPrice.setRoWater("1");
|
|
|
|
+ }
|
|
|
|
+ if ("".equals(productionEnergyPrice.getZlWater())) {
|
|
|
|
+ productionEnergyPrice.setZlWater("1");
|
|
|
|
+ }
|
|
|
|
+ if ("".equals(productionEnergyPrice.getXhWater())) {
|
|
|
|
+ productionEnergyPrice.setXhWater("1");
|
|
|
|
+ }
|
|
|
|
+ if ("".equals(productionEnergyPrice.getQdWater())) {
|
|
|
|
+ productionEnergyPrice.setQdWater("1");
|
|
|
|
+ }
|
|
|
|
+ if ("".equals(productionEnergyPrice.getSwdWater())) {
|
|
|
|
+ productionEnergyPrice.setSwdWater("1");
|
|
|
|
+ }
|
|
|
|
+ if ("".equals(productionEnergyPrice.getEswdWater())) {
|
|
|
|
+ productionEnergyPrice.setEswdWater("1");
|
|
|
|
+ }
|
|
|
|
+ if ("".equals(productionEnergyPrice.getReWater())) {
|
|
|
|
+ productionEnergyPrice.setReWater("1");
|
|
|
|
+ }
|
|
|
|
+ if ("".equals(productionEnergyPrice.getDiwenWater())) {
|
|
|
|
+ productionEnergyPrice.setDiwenWater("1");
|
|
|
|
+ }
|
|
|
|
+ if ("".equals(productionEnergyPrice.getFuSwdYierchun())) {
|
|
|
|
+ productionEnergyPrice.setFuSwdYierchun("1");
|
|
|
|
+ }
|
|
|
|
+ if ("".equals(productionEnergyPrice.getFuEswdYierchun())) {
|
|
|
|
+ productionEnergyPrice.setFuEswdYierchun("1");
|
|
|
|
+ }
|
|
}
|
|
}
|
|
- queryWrapper.orderByAsc("create_time");
|
|
|
|
- return energyMapper.selectList(queryWrapper);
|
|
|
|
|
|
+ QueryWrapper<ProductionEnergy> wrapper = new QueryWrapper<>();
|
|
|
|
+ wrapper.eq(StringUtils.isNotBlank(orgId),"org_id",orgId);
|
|
|
|
+ wrapper.groupBy("ymonth");
|
|
|
|
+ List<ProductionWriteEnergyVo> list ;
|
|
|
|
+ if (timeType == 0){
|
|
|
|
+ list = writeEnergyMapper.selectYear(wrapper,
|
|
|
|
+ productionEnergyPrice.getElectricity() ,
|
|
|
|
+ productionEnergyPrice.getZhengQi(),
|
|
|
|
+ productionEnergyPrice.getDanQi(),
|
|
|
|
+ productionEnergyPrice.getYaSuo(),
|
|
|
|
+ productionEnergyPrice.getRoWater(),
|
|
|
|
+ productionEnergyPrice.getZlWater(),
|
|
|
|
+ productionEnergyPrice.getXhWater(),
|
|
|
|
+ productionEnergyPrice.getQdWater(),
|
|
|
|
+ productionEnergyPrice.getSwdWater(),
|
|
|
|
+ productionEnergyPrice.getEswdWater(),
|
|
|
|
+ productionEnergyPrice.getReWater(),
|
|
|
|
+ productionEnergyPrice.getDiwenWater(),
|
|
|
|
+ productionEnergyPrice.getFuSwdYierchun(),
|
|
|
|
+ productionEnergyPrice.getFuEswdYierchun());
|
|
|
|
+ }else {
|
|
|
|
+ list = writeEnergyMapper.selectMonth(wrapper,
|
|
|
|
+ productionEnergyPrice.getElectricity() ,
|
|
|
|
+ productionEnergyPrice.getZhengQi(),
|
|
|
|
+ productionEnergyPrice.getDanQi(),
|
|
|
|
+ productionEnergyPrice.getYaSuo(),
|
|
|
|
+ productionEnergyPrice.getRoWater(),
|
|
|
|
+ productionEnergyPrice.getZlWater(),
|
|
|
|
+ productionEnergyPrice.getXhWater(),
|
|
|
|
+ productionEnergyPrice.getQdWater(),
|
|
|
|
+ productionEnergyPrice.getSwdWater(),
|
|
|
|
+ productionEnergyPrice.getEswdWater(),
|
|
|
|
+ productionEnergyPrice.getReWater(),
|
|
|
|
+ productionEnergyPrice.getDiwenWater(),
|
|
|
|
+ productionEnergyPrice.getFuSwdYierchun(),
|
|
|
|
+ productionEnergyPrice.getFuEswdYierchun());
|
|
|
|
+ }
|
|
|
|
+ return list;
|
|
|
|
+
|
|
|
|
+
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
}
|