|
@@ -4,14 +4,8 @@ import cn.hutool.core.util.ObjectUtil;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
-import vip.xiaonuo.production.entity.ProductionEnergy;
|
|
|
-import vip.xiaonuo.production.entity.ProductionTarget;
|
|
|
-import vip.xiaonuo.production.entity.ProductionWorkstopPlan;
|
|
|
-import vip.xiaonuo.production.entity.ProductionWritePlan;
|
|
|
-import vip.xiaonuo.production.mapper.ProductionTargetMapper;
|
|
|
-import vip.xiaonuo.production.mapper.ProductionWorkstopPlanMapper;
|
|
|
-import vip.xiaonuo.production.mapper.ProductionWriteEnergyMapper;
|
|
|
-import vip.xiaonuo.production.mapper.ProductionWritePlanMapper;
|
|
|
+import vip.xiaonuo.production.entity.*;
|
|
|
+import vip.xiaonuo.production.mapper.*;
|
|
|
import vip.xiaonuo.production.param.ProductionParam;
|
|
|
import vip.xiaonuo.production.service.IProductionTargetService;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
@@ -20,6 +14,7 @@ import org.springframework.stereotype.Service;
|
|
|
import java.math.BigDecimal;
|
|
|
import java.math.RoundingMode;
|
|
|
import java.text.DecimalFormat;
|
|
|
+import java.util.List;
|
|
|
|
|
|
/**
|
|
|
* <p>
|
|
@@ -38,6 +33,12 @@ public class ProductionTargetServiceImpl extends ServiceImpl<ProductionTargetMap
|
|
|
private ProductionWorkstopPlanMapper planMapper;
|
|
|
@Autowired
|
|
|
private ProductionWritePlanMapper writePlanMapper;
|
|
|
+ @Autowired
|
|
|
+ private ProductionWriteRateMapper rateMapper;
|
|
|
+ @Autowired
|
|
|
+ private ProductionEnergyPriceMapper priceMapper;
|
|
|
+ @Autowired
|
|
|
+ private ProductionWriteEnergyMapper energyMapper;
|
|
|
|
|
|
|
|
|
@Override
|
|
@@ -46,42 +47,113 @@ public class ProductionTargetServiceImpl extends ServiceImpl<ProductionTargetMap
|
|
|
String time = productionParam.getTime();
|
|
|
String produceName = productionParam.getProduceName();
|
|
|
String locationName = productionParam.getLocationName();
|
|
|
- QueryWrapper<ProductionWorkstopPlan> queryWrapper = new QueryWrapper<>();
|
|
|
- queryWrapper.eq(StringUtils.isNotBlank(orgId), "org_id", orgId);
|
|
|
- queryWrapper.between("create_time", time + "-01 00:00:00", time + "-31 23:59:59");
|
|
|
- queryWrapper.select("Convert(IFNULL(sum(actual_production),'0'),decimal(10,2)) actualProduction");
|
|
|
- if (StringUtils.isNotBlank(produceName)) {
|
|
|
- queryWrapper.like("produce_name", produceName);
|
|
|
- }
|
|
|
- queryWrapper.eq(StringUtils.isNotBlank(locationName), "location_name", locationName);
|
|
|
- ProductionWorkstopPlan workstopPlan = planMapper.selectOne(queryWrapper);//实际产量
|
|
|
+// Integer dataType = productionParam.getDataType();
|
|
|
+ ProductionTarget productionTarget = new ProductionTarget();
|
|
|
+ /* if (1 == dataType) {
|
|
|
+ QueryWrapper<ProductionWorkstopPlan> queryWrapper = new QueryWrapper<>();
|
|
|
+ queryWrapper.eq(StringUtils.isNotBlank(orgId), "org_id", orgId);
|
|
|
+ queryWrapper.between("create_time", time + "-01 00:00:00", time + "-31 23:59:59");
|
|
|
+ queryWrapper.select("Convert(IFNULL(sum(actual_production),'0'),decimal(10,2)) actualProduction");
|
|
|
+ if (StringUtils.isNotBlank(produceName)) {
|
|
|
+ queryWrapper.like("produce_name", produceName);
|
|
|
+ }
|
|
|
+ queryWrapper.eq(StringUtils.isNotBlank(locationName), "location_name", locationName);
|
|
|
+ ProductionWorkstopPlan workstopPlan = planMapper.selectOne(queryWrapper);//实际产量
|
|
|
|
|
|
- QueryWrapper<ProductionWritePlan> queryWrapper1 = new QueryWrapper<>();
|
|
|
- queryWrapper1.eq(StringUtils.isNotBlank(orgId), "org_id", orgId);
|
|
|
- queryWrapper1.eq(StringUtils.isNotBlank(locationName), "location_name", locationName);
|
|
|
- queryWrapper1.eq(StringUtils.isNotBlank(produceName), "production_name", produceName);
|
|
|
- queryWrapper1.between("create_time", time + "-01 00:00:00", time + "-31 23:59:59");
|
|
|
- queryWrapper1.select(" Convert(IFNULL(sum(production_plan),'0'),decimal(10,2)) productionPlan");
|
|
|
- ProductionWritePlan writePlan = writePlanMapper.selectOne(queryWrapper1);//计划生产量
|
|
|
+ QueryWrapper<ProductionWritePlan> queryWrapper1 = new QueryWrapper<>();
|
|
|
+ queryWrapper1.eq(StringUtils.isNotBlank(orgId), "org_id", orgId);
|
|
|
+ queryWrapper1.eq(StringUtils.isNotBlank(locationName), "location_name", locationName);
|
|
|
+ queryWrapper1.eq(StringUtils.isNotBlank(produceName), "production_name", produceName);
|
|
|
+ queryWrapper1.between("create_time", time + "-01 00:00:00", time + "-31 23:59:59");
|
|
|
+ queryWrapper1.select(" Convert(IFNULL(sum(production_plan),'0'),decimal(10,2)) productionPlan," +
|
|
|
+ "Convert(IFNULL(sum(actual_production),'0'),decimal(10,2)) actualProduction");
|
|
|
+ ProductionWritePlan writePlan = writePlanMapper.selectOne(queryWrapper1);//计划生产量
|
|
|
|
|
|
- ProductionTarget productionTarget = new ProductionTarget();
|
|
|
- if (ObjectUtil.isEmpty(writePlan) || "0.00".equals(writePlan.getProductionPlan())) {
|
|
|
- productionTarget.setPlanProduction("0");
|
|
|
- productionTarget.setPlanCompleteRate("0");
|
|
|
- } else {
|
|
|
- productionTarget.setPlanProduction(writePlan.getProductionPlan());
|
|
|
- double v = Double.valueOf(workstopPlan.getActualProduction()) / Double.valueOf(writePlan.getProductionPlan());
|
|
|
- if (v > 1.0) {
|
|
|
- productionTarget.setPlanCompleteRate("100");
|
|
|
+ if (ObjectUtil.isEmpty(writePlan) || "0.00".equals(writePlan.getProductionPlan())) {
|
|
|
+ productionTarget.setPlanProduction("0");
|
|
|
+ productionTarget.setPlanCompleteRate("0");
|
|
|
+ } else {
|
|
|
+ productionTarget.setPlanProduction(writePlan.getProductionPlan());
|
|
|
+ double v = Double.valueOf(workstopPlan.getActualProduction()) / Double.valueOf(writePlan.getProductionPlan());
|
|
|
+ if (v > 1.0) {
|
|
|
+ productionTarget.setPlanCompleteRate("100");
|
|
|
+ } else {
|
|
|
+ DecimalFormat def = new DecimalFormat("0.00");
|
|
|
+ productionTarget.setPlanCompleteRate(def.format(v * 100));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ productionTarget.setActualProduction(workstopPlan.getActualProduction());
|
|
|
+ } else {*/
|
|
|
+ QueryWrapper<ProductionWritePlan> queryWrapper1 = new QueryWrapper<>();
|
|
|
+ queryWrapper1.eq(StringUtils.isNotBlank(orgId), "org_id", orgId);
|
|
|
+ queryWrapper1.eq(StringUtils.isNotBlank(locationName), "location_name", locationName);
|
|
|
+ queryWrapper1.eq(StringUtils.isNotBlank(produceName), "production_name", produceName);
|
|
|
+ queryWrapper1.between("create_time", time + "-01 00:00:00", time + "-31 23:59:59");
|
|
|
+ queryWrapper1.select(" Convert(IFNULL(sum(production_plan),'0'),decimal(10,2)) productionPlan," +
|
|
|
+ "Convert(IFNULL(sum(actual_production),'0'),decimal(10,2)) actualProduction");
|
|
|
+ ProductionWritePlan writePlan = writePlanMapper.selectOne(queryWrapper1);//计划生产量
|
|
|
+
|
|
|
+
|
|
|
+ if (ObjectUtil.isEmpty(writePlan) || "0.00".equals(writePlan.getProductionPlan())) {
|
|
|
+ productionTarget.setPlanProduction("0");
|
|
|
+ productionTarget.setPlanCompleteRate("0");
|
|
|
} else {
|
|
|
- DecimalFormat def = new DecimalFormat("0.00");
|
|
|
- productionTarget.setPlanCompleteRate(def.format(v * 100));
|
|
|
+ productionTarget.setPlanProduction(writePlan.getProductionPlan());
|
|
|
+ double v = Double.valueOf(writePlan.getActualProduction()) / Double.valueOf(writePlan.getProductionPlan());
|
|
|
+ if (v > 1.0) {
|
|
|
+ productionTarget.setPlanCompleteRate("100");
|
|
|
+ } else {
|
|
|
+ DecimalFormat def = new DecimalFormat("0.00");
|
|
|
+ productionTarget.setPlanCompleteRate(def.format(v * 100));
|
|
|
+ }
|
|
|
}
|
|
|
+ productionTarget.setActualProduction(writePlan.getActualProduction());
|
|
|
+// }
|
|
|
+
|
|
|
+ QueryWrapper<ProductionWriteRate> rateQueryWrapper = new QueryWrapper<>();
|
|
|
+ rateQueryWrapper.eq(StringUtils.isNotBlank(orgId), "org_id", orgId);
|
|
|
+ rateQueryWrapper.between("create_time", time + "-01 00:00:00", time + "-31 23:59:59");
|
|
|
+ if (StringUtils.isNotBlank(produceName)) {
|
|
|
+ rateQueryWrapper.like("produce_name", produceName);
|
|
|
}
|
|
|
+ rateQueryWrapper.eq(StringUtils.isNotBlank(locationName), "location_name", locationName);
|
|
|
+ rateQueryWrapper.select(" convert(IFNULL(avg(production_rate),'0'),decimal(10,2)) productionRate");
|
|
|
+ ProductionWriteRate writeRate = rateMapper.selectOne(rateQueryWrapper);
|
|
|
+ productionTarget.setReceiveRate(writeRate.getProductionRate());
|
|
|
|
|
|
- productionTarget.setActualProduction(workstopPlan.getActualProduction());
|
|
|
- productionTarget.setReceiveRate("0");
|
|
|
- productionTarget.setProductionEnergy("0");
|
|
|
+ QueryWrapper<ProductionWriteEnergy> energyQueryWrapper = new QueryWrapper<>();
|
|
|
+ energyQueryWrapper.eq(StringUtils.isNotBlank(orgId), "org_id", orgId);
|
|
|
+ if (StringUtils.isNotBlank(produceName)) {
|
|
|
+ energyQueryWrapper.like("produce_name", produceName);
|
|
|
+ }
|
|
|
+ rateQueryWrapper.between("create_time", time + "-01 00:00:00", time + "-31 23:59:59");
|
|
|
+ energyQueryWrapper.eq(StringUtils.isNotBlank(locationName), "location_name", locationName);
|
|
|
+ energyQueryWrapper.select("IFNULL(sum(electricity),'0') electricity,IFNULL(sum(zheng_qi),'0') zhengQi,IFNULL(sum(dan_qi),'0') danQi" +
|
|
|
+ ",IFNULL(sum(ya_suo),'0') yaSuo,IFNULL(sum(ro_water),'0') roWater,IFNULL(sum(zl_water),'0') zlWater, IFNULL(sum(xh_water),'0') xhWater" +
|
|
|
+ ",IFNULL(sum(qd_water),'0') qdwater,IFNULL(sum(swd_water),'0') swdWater,IFNULL(sum(eswd_water),'0') eswdWater,IFNULL(sum(re_water),'0') reWater" +
|
|
|
+ ",IFNULL(sum(diwen_water),'0') diwenWater,IFNULL(sum(fu_swd_yierchun),'0') fuSwdYierchun" +
|
|
|
+ ",IFNULL(sum(fu_eswd_yierchun),'0') fuEswdYierchun,location_id locationId");
|
|
|
+ energyQueryWrapper.groupBy("location_id");
|
|
|
+ List<ProductionWriteEnergy> energyList = energyMapper.selectList(energyQueryWrapper);
|
|
|
+ Double count = 0.00;
|
|
|
+ for (ProductionWriteEnergy energy : energyList) {
|
|
|
+ if (energy.getLocationId() != null) {
|
|
|
+ QueryWrapper<ProductionEnergyPrice> priceQueryWrapper = new QueryWrapper<>();
|
|
|
+ priceQueryWrapper.eq("location_id", energy.getLocationId());
|
|
|
+ ProductionEnergyPrice energyPrice = priceMapper.selectOne(priceQueryWrapper);
|
|
|
+ if (ObjectUtil.isNotEmpty(energyPrice)) {
|
|
|
+ count = count + Double.valueOf(energy.getElectricity()) * Double.valueOf(energyPrice.getElectricity())+Double.valueOf(energy.getZhengQi()) * Double.valueOf(energyPrice.getZhengQi())
|
|
|
+ +Double.valueOf(energy.getDanQi()) * Double.valueOf(energyPrice.getDanQi())+Double.valueOf(energy.getYaSuo()) * Double.valueOf(energyPrice.getYaSuo())+
|
|
|
+ Double.valueOf(energy.getRoWater()) * Double.valueOf(energyPrice.getRoWater())+Double.valueOf(energy.getZlWater()) * Double.valueOf(energyPrice.getZiWater())+
|
|
|
+ Double.valueOf(energy.getXhWater()) * Double.valueOf(energyPrice.getXunWater())+Double.valueOf(energy.getQdWater()) * Double.valueOf(energyPrice.getQiWater())+
|
|
|
+ Double.valueOf(energy.getSwdWater()) * Double.valueOf(energyPrice.getFuShiwuWater())+Double.valueOf(energy.getEswdWater()) * Double.valueOf(energyPrice.getFuErshiwuWater())+
|
|
|
+ Double.valueOf(energy.getReWater()) * Double.valueOf(energyPrice.getReWater())+Double.valueOf(energy.getDiwenWater()) * Double.valueOf(energyPrice.getDiwenWater())+
|
|
|
+ Double.valueOf(energy.getFuSwdYierchun()) * Double.valueOf(energyPrice.getFushiwuYierchun())+Double.valueOf(energy.getFuEswdYierchun()) * Double.valueOf(energyPrice.getFuershiwuYierchun());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ DecimalFormat def = new DecimalFormat("0.00");
|
|
|
+ productionTarget.setProductionEnergy(def.format(count));
|
|
|
|
|
|
return productionTarget;
|
|
|
}
|