|
@@ -1,21 +1,34 @@
|
|
|
package vip.xiaonuo.production.service.impl;
|
|
|
|
|
|
+import cn.hutool.core.date.DateTime;
|
|
|
+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.toolkit.StringUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import vip.xiaonuo.production.entity.*;
|
|
|
+import vip.xiaonuo.production.entity.vo.ProductionLocationVo;
|
|
|
import vip.xiaonuo.production.mapper.*;
|
|
|
import vip.xiaonuo.production.param.ProductionParam;
|
|
|
+import vip.xiaonuo.production.param.ProductionVoParam;
|
|
|
+import vip.xiaonuo.production.param.TargetListDetailVo;
|
|
|
+import vip.xiaonuo.production.param.TargetListDetailVos;
|
|
|
import vip.xiaonuo.production.service.IProductionTargetService;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
+import vip.xiaonuo.production.service.IProductionWorkstopPlanService;
|
|
|
+import vip.xiaonuo.purchase.entity.PurchaseOrder;
|
|
|
+import vip.xiaonuo.purchase.entity.vo.PurchaseOrderVo;
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
import java.math.RoundingMode;
|
|
|
import java.text.DecimalFormat;
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.Date;
|
|
|
import java.util.List;
|
|
|
|
|
|
+import static vip.xiaonuo.money.service.impl.MoneyBusinessServiceImpl.calculateYOYChange;
|
|
|
+
|
|
|
/**
|
|
|
* <p>
|
|
|
* 生产管控指标 服务实现类
|
|
@@ -39,7 +52,8 @@ public class ProductionTargetServiceImpl extends ServiceImpl<ProductionTargetMap
|
|
|
private ProductionEnergyPriceMapper priceMapper;
|
|
|
@Autowired
|
|
|
private ProductionWriteEnergyMapper energyMapper;
|
|
|
-
|
|
|
+ @Autowired
|
|
|
+ private IProductionWorkstopPlanService planService;
|
|
|
|
|
|
@Override
|
|
|
public ProductionTarget getTarget(ProductionParam productionParam) {
|
|
@@ -202,4 +216,152 @@ public class ProductionTargetServiceImpl extends ServiceImpl<ProductionTargetMap
|
|
|
return productionTarget;
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public List<TargetListDetailVo> getListDetail(ProductionParam productionParam) {
|
|
|
+ String orgId = productionParam.getOrgId();
|
|
|
+ ProductionVoParam productionVoParam = new ProductionVoParam();
|
|
|
+ productionVoParam.setOrgId(orgId);
|
|
|
+ List<ProductionLocationVo> productionLocationVos = planService.listLocation(productionVoParam);
|
|
|
+ QueryWrapper<ProductionWritePlan> wrapper = new QueryWrapper<>();
|
|
|
+
|
|
|
+ List<TargetListDetailVo> targetListDetailVos = new ArrayList<>();
|
|
|
+ for (ProductionLocationVo productionLocationVo : productionLocationVos) {
|
|
|
+ wrapper.clear();
|
|
|
+ wrapper.eq(StringUtils.isNotBlank(orgId), "org_id", orgId).orderByAsc("create_time");
|
|
|
+ wrapper.eq("location_id",productionLocationVo.getLocationId());
|
|
|
+ wrapper.groupBy("ymonth").orderByAsc("ymonth");
|
|
|
+
|
|
|
+ TargetListDetailVo targetListDetailVo = new TargetListDetailVo();
|
|
|
+ targetListDetailVo.setChenJian(productionLocationVo.getLocationName());
|
|
|
+ List<TargetListDetailVos> listDetail = energyMapper.getListDetail(wrapper);
|
|
|
+ if (ObjectUtil.isNotEmpty(listDetail)){
|
|
|
+ for (TargetListDetailVos listDetailVos : listDetail) {
|
|
|
+ if (StringUtils.isBlank(listDetailVos.getActualProduction()) || "0".equals(listDetailVos.getActualProduction())){
|
|
|
+ listDetailVos.setActualProduction("0%");
|
|
|
+ }
|
|
|
+ else if (StringUtils.isBlank(listDetailVos.getProductionPlan()) || "0".equals(listDetailVos.getProductionPlan())){
|
|
|
+ listDetailVos.setActualProduction("100%");
|
|
|
+ }else {
|
|
|
+ listDetailVos.setActualProduction(calculateYOYChange(Double.parseDouble(listDetailVos.getProductionPlan()),Double.parseDouble(listDetailVos.getProductionPlan())));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ targetListDetailVo.setValues(listDetail);
|
|
|
+ targetListDetailVos.add(targetListDetailVo);
|
|
|
+ }
|
|
|
+
|
|
|
+ return targetListDetailVos;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public List<TargetListDetailVo> getListShouLvChengDetail(ProductionParam productionParam) {
|
|
|
+ String orgId = productionParam.getOrgId();
|
|
|
+ ProductionVoParam productionVoParam = new ProductionVoParam();
|
|
|
+ productionVoParam.setOrgId(orgId);
|
|
|
+ List<ProductionLocationVo> productionLocationVos = planService.listLocation(productionVoParam);
|
|
|
+ QueryWrapper<ProductionWritePlan> wrapper = new QueryWrapper<>();
|
|
|
+
|
|
|
+ List<TargetListDetailVo> targetListDetailVos = new ArrayList<>();
|
|
|
+ for (ProductionLocationVo productionLocationVo : productionLocationVos) {
|
|
|
+ wrapper.clear();
|
|
|
+ wrapper.eq(StringUtils.isNotBlank(orgId), "org_id", orgId).orderByAsc("create_time");
|
|
|
+ wrapper.eq("location_id", productionLocationVo.getLocationId());
|
|
|
+ wrapper.groupBy("ymonth").orderByAsc("ymonth");
|
|
|
+
|
|
|
+ TargetListDetailVo targetListDetailVo = new TargetListDetailVo();
|
|
|
+ targetListDetailVo.setChenJian(productionLocationVo.getLocationName());
|
|
|
+ targetListDetailVo.setValues(rateMapper.productionParam(wrapper));
|
|
|
+ targetListDetailVos.add(targetListDetailVo);
|
|
|
+ }
|
|
|
+ return targetListDetailVos;
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public List<TargetListDetailVo> getListNengHaoDetail(ProductionParam productionParam) {
|
|
|
+ String orgId = productionParam.getOrgId();
|
|
|
+ ProductionVoParam productionVoParam = new ProductionVoParam();
|
|
|
+ productionVoParam.setOrgId(orgId);
|
|
|
+ List<ProductionLocationVo> productionLocationVos = planService.listLocation(productionVoParam);
|
|
|
+ QueryWrapper<ProductionWritePlan> wrapper = new QueryWrapper<>();
|
|
|
+
|
|
|
+ List<TargetListDetailVo> targetListDetailVos = new ArrayList<>();
|
|
|
+ for (ProductionLocationVo productionLocationVo : productionLocationVos) {
|
|
|
+ wrapper.clear();
|
|
|
+ wrapper.eq(StringUtils.isNotBlank(orgId), "org_id", orgId).orderByAsc("create_time");
|
|
|
+ wrapper.eq("location_id", productionLocationVo.getLocationId());
|
|
|
+ wrapper.groupBy("ymonth").orderByAsc("ymonth");
|
|
|
+
|
|
|
+ TargetListDetailVo targetListDetailVo = new TargetListDetailVo();
|
|
|
+ targetListDetailVo.setChenJian(productionLocationVo.getLocationName());
|
|
|
+ QueryWrapper<ProductionEnergyPrice> priceQueryWrapper = new QueryWrapper<>();
|
|
|
+ List<ProductionEnergyPrice> energyPrice = priceMapper.selectList(priceQueryWrapper);
|
|
|
+ ProductionEnergyPrice productionEnergyPrice = energyPrice.get(0);
|
|
|
+ if (ObjectUtil.isNotEmpty(energyPrice)) {
|
|
|
+
|
|
|
+ if ("".equals(productionEnergyPrice.getElectricity())) {
|
|
|
+ productionEnergyPrice.setElectricity("0");
|
|
|
+ }
|
|
|
+ if ("".equals(productionEnergyPrice.getZhengQi())) {
|
|
|
+ productionEnergyPrice.setZhengQi("0");
|
|
|
+ }
|
|
|
+ if ("".equals(productionEnergyPrice.getDanQi())) {
|
|
|
+ productionEnergyPrice.setDanQi("0");
|
|
|
+ }
|
|
|
+ if ("".equals(productionEnergyPrice.getYaSuo())) {
|
|
|
+ productionEnergyPrice.setYaSuo("0");
|
|
|
+ }
|
|
|
+ if ("".equals(productionEnergyPrice.getRoWater())) {
|
|
|
+ productionEnergyPrice.setRoWater("0");
|
|
|
+ }
|
|
|
+ if ("".equals(productionEnergyPrice.getZlWater())) {
|
|
|
+ productionEnergyPrice.setZlWater("0");
|
|
|
+ }
|
|
|
+ if ("".equals(productionEnergyPrice.getXhWater())) {
|
|
|
+ productionEnergyPrice.setXhWater("0");
|
|
|
+ }
|
|
|
+ if ("".equals(productionEnergyPrice.getQdWater())) {
|
|
|
+ productionEnergyPrice.setQdWater("0");
|
|
|
+ }
|
|
|
+ if ("".equals(productionEnergyPrice.getSwdWater())) {
|
|
|
+ productionEnergyPrice.setSwdWater("0");
|
|
|
+ }
|
|
|
+ if ("".equals(productionEnergyPrice.getEswdWater())) {
|
|
|
+ productionEnergyPrice.setEswdWater("0");
|
|
|
+ }
|
|
|
+ if ("".equals(productionEnergyPrice.getReWater())) {
|
|
|
+ productionEnergyPrice.setReWater("0");
|
|
|
+ }
|
|
|
+ if ("".equals(productionEnergyPrice.getDiwenWater())) {
|
|
|
+ productionEnergyPrice.setDiwenWater("0");
|
|
|
+ }
|
|
|
+ if ("".equals(productionEnergyPrice.getFuSwdYierchun())) {
|
|
|
+ productionEnergyPrice.setFuSwdYierchun("0");
|
|
|
+ }
|
|
|
+ if ("".equals(productionEnergyPrice.getFuEswdYierchun())) {
|
|
|
+ productionEnergyPrice.setFuEswdYierchun("0");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ targetListDetailVo.setValues(rateMapper.getListNengHaoDetail(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()
|
|
|
+ ));
|
|
|
+ targetListDetailVos.add(targetListDetailVo);
|
|
|
+
|
|
|
+ }
|
|
|
+ return targetListDetailVos;
|
|
|
+ }
|
|
|
+
|
|
|
}
|