|
@@ -6,8 +6,10 @@ import com.alibaba.fastjson2.JSONObject;
|
|
|
import com.jjt.biz.service.IApiYrService;
|
|
|
import com.jjt.biz.vo.*;
|
|
|
import com.jjt.calc.domain.TwinCalcDayYhj;
|
|
|
+import com.jjt.calc.domain.TwinCalcHourEnergy;
|
|
|
import com.jjt.calc.domain.TwinCalcHourYhj;
|
|
|
import com.jjt.calc.service.ITwinCalcDayYhjService;
|
|
|
+import com.jjt.calc.service.ITwinCalcHourEnergyService;
|
|
|
import com.jjt.calc.service.ITwinCalcHourYhjService;
|
|
|
import com.jjt.common.constant.CacheConstants;
|
|
|
import com.jjt.common.core.redis.RedisCache;
|
|
@@ -20,7 +22,10 @@ import com.jjt.rz.service.ITwinDeviceRzService;
|
|
|
import com.jjt.rz.service.ITwinDeviceTypeService;
|
|
|
import com.jjt.rz.vo.CompareVO;
|
|
|
import com.jjt.ws.domain.TwinRzCalcMonth;
|
|
|
+import com.jjt.ws.domain.TwinWorkshop;
|
|
|
+import com.jjt.ws.domain.TwinWorkshopEnergy;
|
|
|
import com.jjt.ws.service.ITwinRzCalcMonthService;
|
|
|
+import com.jjt.ws.service.ITwinWorkshopService;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
@@ -61,7 +66,10 @@ public class ApiYrServiceImpl implements IApiYrService {
|
|
|
private ITwinDeviceTypeService typeService;
|
|
|
@Resource
|
|
|
ITwinCalcHourBpOutService bpOutService;
|
|
|
-
|
|
|
+ @Resource
|
|
|
+ private ITwinCalcHourEnergyService energyService;
|
|
|
+ @Resource
|
|
|
+ private ITwinWorkshopService wsService;
|
|
|
|
|
|
/**
|
|
|
* 获取产线状态
|
|
@@ -321,15 +329,54 @@ public class ApiYrServiceImpl implements IApiYrService {
|
|
|
List<CompareVO> result = new ArrayList<>();
|
|
|
for (YrCompareBackReq req : reqs) {
|
|
|
CompareVO vo = itemProcessor(req, flag);
|
|
|
- int totalLength = getTotalLength(req);
|
|
|
- vo.setLength(totalLength);
|
|
|
-
|
|
|
+ vo.setLength(getTotalLength(req));
|
|
|
vo.setBp(getBpLength(req));
|
|
|
+ vo.setOil(getOil(req));
|
|
|
result.add(vo);
|
|
|
}
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ private Map<String, Object> getParams(YrCompareBackReq req) {
|
|
|
+ Map<String, Object> params = new HashMap<>(16);
|
|
|
+ params.put("sTime", DateUtils.toDate(req.getStart()));
|
|
|
+ params.put("eTime", DateUtils.toDate(req.getEnd()));
|
|
|
+ return params;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取用油情况
|
|
|
+ *
|
|
|
+ * @param req 输入参数
|
|
|
+ * @return 结果
|
|
|
+ */
|
|
|
+ private BigDecimal getOil(YrCompareBackReq req) {
|
|
|
+ TwinCalcHourEnergy energySearch = new TwinCalcHourEnergy();
|
|
|
+ energySearch.setParams(getParams(req));
|
|
|
+ List<TwinCalcHourEnergy> list = energyService.selectTwinCalcHourEnergyList(energySearch);
|
|
|
+ List<TwinWorkshop> wsList = wsService.selectTwinWorkshopList(new TwinWorkshop());
|
|
|
+ //存储能源ID和车间ID关系
|
|
|
+ Map<Long, TwinWorkshop> wsMap = new HashMap<>(16);
|
|
|
+ wsList.forEach(ws -> {
|
|
|
+ List<TwinWorkshopEnergy> energyList = wsService.selectTwinWorkshopByWsId(ws.getWsId()).getTwinWorkshopEnergyList();
|
|
|
+ energyList.forEach(o -> wsMap.put(o.getEnergyId(), ws));
|
|
|
+ });
|
|
|
+ BigDecimal total = BigDecimal.ZERO;
|
|
|
+ for (TwinCalcHourEnergy obj : list) {
|
|
|
+ obj.setTeam();
|
|
|
+ TwinWorkshop ws = wsMap.get(obj.getEnergyId());
|
|
|
+ if (ws == null) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ if (ws.getWsCode().contains("WS03-Y")) {
|
|
|
+ total = total.add(obj.getDataValue());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //先直接除以8条产线
|
|
|
+ return total.divide(BigDecimal.valueOf(8), 2, RoundingMode.HALF_UP);
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 获取白坯投放量
|
|
|
*
|
|
@@ -340,15 +387,11 @@ public class ApiYrServiceImpl implements IApiYrService {
|
|
|
//获取印花产量数据
|
|
|
TwinCalcHourBpOut bpOut = new TwinCalcHourBpOut();
|
|
|
bpOut.setDeviceId(req.getLine());
|
|
|
- Map<String, Object> params = new HashMap<>(16);
|
|
|
- params.put("sTime", DateUtils.toDate(req.getStart()));
|
|
|
- params.put("eTime", DateUtils.toDate(req.getEnd()));
|
|
|
- bpOut.setParams(params);
|
|
|
+ bpOut.setParams(getParams(req));
|
|
|
List<TwinCalcHourBpOut> yhjList = bpOutService.selectTwinCalcHourBpOutList(bpOut);
|
|
|
- int totalLength = yhjList.stream()
|
|
|
+ return yhjList.stream()
|
|
|
.mapToInt(TwinCalcHourBpOut::getLength)
|
|
|
.sum();
|
|
|
- return totalLength;
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -361,15 +404,11 @@ public class ApiYrServiceImpl implements IApiYrService {
|
|
|
//获取印花产量数据
|
|
|
TwinCalcHourYhj yhjSearch = new TwinCalcHourYhj();
|
|
|
yhjSearch.setDeviceId(req.getLine());
|
|
|
- Map<String, Object> params = new HashMap<>(16);
|
|
|
- params.put("sTime", DateUtils.toDate(req.getStart()));
|
|
|
- params.put("eTime", DateUtils.toDate(req.getEnd()));
|
|
|
- yhjSearch.setParams(params);
|
|
|
+ yhjSearch.setParams(getParams(req));
|
|
|
List<TwinCalcHourYhj> yhjList = yhjService.selectTwinCalcHourYhjList(yhjSearch);
|
|
|
- int totalLength = yhjList.stream()
|
|
|
+ return yhjList.stream()
|
|
|
.mapToInt(TwinCalcHourYhj::getLength)
|
|
|
.sum();
|
|
|
- return totalLength;
|
|
|
}
|
|
|
|
|
|
private CompareVO itemProcessor(YrCompareBackReq req, boolean flag) {
|
|
@@ -418,43 +457,43 @@ public class ApiYrServiceImpl implements IApiYrService {
|
|
|
|
|
|
// 计算平均值的方法
|
|
|
BiFunction<List<CompareVO.Para>, Predicate<Map.Entry<String, Object>>, BigDecimal> calculateAvg = (list, filter) ->
|
|
|
- list.stream()
|
|
|
- .flatMap(item -> item.getPara().entrySet().stream())
|
|
|
- .filter(filter)
|
|
|
- .map(valueExtractor)
|
|
|
- .reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
+ list.stream()
|
|
|
+ .flatMap(item -> item.getPara().entrySet().stream())
|
|
|
+ .filter(filter)
|
|
|
+ .map(valueExtractor)
|
|
|
+ .reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
|
|
|
// 前整车间计算
|
|
|
List<CompareVO.Para> qzDx = vo.getQz().getDxPara();
|
|
|
List<CompareVO.Para> qzTg = vo.getQz().getTgPara();
|
|
|
|
|
|
vo.getQz().setHxAvgTemp(qzDx.isEmpty() ? BigDecimal.ZERO :
|
|
|
- calculateAvg.apply(qzDx, entry -> entry.getKey().contains("烘箱温度"))
|
|
|
- .divide(new BigDecimal(qzDx.size() * 4), 2, RoundingMode.HALF_UP));
|
|
|
+ calculateAvg.apply(qzDx, entry -> entry.getKey().contains("烘箱温度"))
|
|
|
+ .divide(new BigDecimal(qzDx.size() * 4), 2, RoundingMode.HALF_UP));
|
|
|
|
|
|
vo.getQz().setTgAvgTemp(qzTg.isEmpty() ? BigDecimal.ZERO :
|
|
|
- calculateAvg.apply(qzTg, entry -> entry.getKey().contains("烫辊") && entry.getKey().contains("温度"))
|
|
|
- .divide(new BigDecimal(qzTg.size() * 2), 2, RoundingMode.HALF_UP));
|
|
|
+ calculateAvg.apply(qzTg, entry -> entry.getKey().contains("烫辊") && entry.getKey().contains("温度"))
|
|
|
+ .divide(new BigDecimal(qzTg.size() * 2), 2, RoundingMode.HALF_UP));
|
|
|
|
|
|
vo.getQz().setTgAvgSpeed(qzTg.isEmpty() ? BigDecimal.ZERO :
|
|
|
- calculateAvg.apply(qzTg, entry -> entry.getKey().contains("走布速度"))
|
|
|
- .divide(new BigDecimal(qzTg.size()), 2, RoundingMode.HALF_UP));
|
|
|
+ calculateAvg.apply(qzTg, entry -> entry.getKey().contains("走布速度"))
|
|
|
+ .divide(new BigDecimal(qzTg.size()), 2, RoundingMode.HALF_UP));
|
|
|
|
|
|
// 后整车间计算
|
|
|
List<CompareVO.Para> hzDx = vo.getHz().getDxPara();
|
|
|
List<CompareVO.Para> hzTg = vo.getHz().getTgPara();
|
|
|
|
|
|
vo.getHz().setHxAvgTemp(hzDx.isEmpty() ? BigDecimal.ZERO :
|
|
|
- calculateAvg.apply(hzDx, entry -> entry.getKey().contains("烘箱温度"))
|
|
|
- .divide(new BigDecimal(hzDx.size() * 4), 2, RoundingMode.HALF_UP));
|
|
|
+ calculateAvg.apply(hzDx, entry -> entry.getKey().contains("烘箱温度"))
|
|
|
+ .divide(new BigDecimal(hzDx.size() * 4), 2, RoundingMode.HALF_UP));
|
|
|
|
|
|
vo.getHz().setTgAvgTemp(hzTg.isEmpty() ? BigDecimal.ZERO :
|
|
|
- calculateAvg.apply(hzTg, entry -> entry.getKey().contains("烫辊") && entry.getKey().contains("温度"))
|
|
|
- .divide(new BigDecimal(hzTg.size() * 2), 2, RoundingMode.HALF_UP));
|
|
|
+ calculateAvg.apply(hzTg, entry -> entry.getKey().contains("烫辊") && entry.getKey().contains("温度"))
|
|
|
+ .divide(new BigDecimal(hzTg.size() * 2), 2, RoundingMode.HALF_UP));
|
|
|
|
|
|
vo.getHz().setTgAvgSpeed(hzTg.isEmpty() ? BigDecimal.ZERO :
|
|
|
- calculateAvg.apply(hzTg, entry -> entry.getKey().contains("走布速度"))
|
|
|
- .divide(new BigDecimal(hzTg.size()), 2, RoundingMode.HALF_UP));
|
|
|
+ calculateAvg.apply(hzTg, entry -> entry.getKey().contains("走布速度"))
|
|
|
+ .divide(new BigDecimal(hzTg.size()), 2, RoundingMode.HALF_UP));
|
|
|
|
|
|
if (!flag) {
|
|
|
vo.getQz().setDxPara(null);
|