|
|
@@ -2,11 +2,11 @@ package com.jjt.order.controller;
|
|
|
|
|
|
import com.jjt.biz.vo.GramMassDetail;
|
|
|
import com.jjt.calc.domain.TwinCalcDay;
|
|
|
-import com.jjt.calc.domain.TwinFormulaInfo;
|
|
|
import com.jjt.calc.service.ITwinCalcDayService;
|
|
|
import com.jjt.calc.service.ITwinFormulaInfoService;
|
|
|
import com.jjt.common.constant.CacheConstants;
|
|
|
import com.jjt.common.core.controller.BaseController;
|
|
|
+import com.jjt.common.core.domain.AjaxResult;
|
|
|
import com.jjt.common.core.redis.RedisCache;
|
|
|
import com.jjt.common.utils.DateUtils;
|
|
|
import com.jjt.order.domain.TwinOrder;
|
|
|
@@ -141,19 +141,27 @@ public class OrderApiController extends BaseController {
|
|
|
@GetMapping("/api/order/query")
|
|
|
@CrossOrigin(origins = "*")
|
|
|
@ResponseBody
|
|
|
- public List<TwinOrder> query(@RequestParam String start, @RequestParam String end, @RequestParam Integer days) {
|
|
|
+ public AjaxResult query(@RequestParam String start, @RequestParam String end, @RequestParam Integer days) {
|
|
|
List<TwinOrder> orderList = orderService.selectTwinOrderListByDate(start, end);
|
|
|
|
|
|
//白柸布库存
|
|
|
List<VmsStock> stocks = mssqlService.vmsStock();
|
|
|
//设备配方信息
|
|
|
List<GramMassDetail> infos = redisCache.getCacheObject(CacheConstants.INDEX_GRAM_MASS_DETAIL);
|
|
|
-// List<TwinFormulaInfo> infos = formulaInfoService.selectTwinFormulaInfoList(new TwinFormulaInfo());
|
|
|
//当前产量处理
|
|
|
Date sd = DateUtils.toDate(LocalDateTime.now().minusHours(7).toLocalDate().minusDays(1));
|
|
|
List<TwinCalcDay> dayList = dayService.selectTwinCalcDayListByTime(sd, sd);
|
|
|
//按设备ID分组
|
|
|
Map<Long, TwinCalcDay> dayMap = dayList.stream().collect(Collectors.toMap(TwinCalcDay::getDeviceId, o -> o));
|
|
|
+ infos.forEach(info -> {
|
|
|
+ TwinCalcDay day = dayMap.get((long)info.getFormula_data_2());
|
|
|
+ double ycl = day.getWeight().multiply(BigDecimal.valueOf(days)).doubleValue();
|
|
|
+ info.setKcl(0d);
|
|
|
+ info.setYcl(ycl);
|
|
|
+ info.setXql(0d);
|
|
|
+ info.setSy();
|
|
|
+ });
|
|
|
+ Map<Integer, GramMassDetail> deviceMap = infos.stream().collect(Collectors.toMap(GramMassDetail::getFormula_data_2, o -> o));
|
|
|
|
|
|
for (TwinOrder twinOrder : orderList) {
|
|
|
List<BomVO> bomVOList = new ArrayList<>();
|
|
|
@@ -170,16 +178,20 @@ public class OrderApiController extends BaseController {
|
|
|
}
|
|
|
//匹配生产设备
|
|
|
List<GramMassDetail> matchFormula = oe.matchFormula(spec, infos);
|
|
|
+ double totalWeight = todList.stream().mapToDouble(o -> o.getWeight().doubleValue()).sum();
|
|
|
BigDecimal cl = BigDecimal.ZERO;
|
|
|
for (GramMassDetail match : matchFormula) {
|
|
|
- TwinCalcDay day = dayMap.get(match.getFormula_data_2());
|
|
|
+ GramMassDetail gd = deviceMap.get(match.getFormula_data_2());
|
|
|
+ TwinCalcDay day = dayMap.get((long)match.getFormula_data_2());
|
|
|
if (day != null) {
|
|
|
cl = cl.add(day.getWeight());
|
|
|
}
|
|
|
+ gd.setKcl(Double.valueOf(kc));
|
|
|
+ gd.setXql(totalWeight);
|
|
|
+ gd.setSy();
|
|
|
}
|
|
|
|
|
|
cl = cl.multiply(BigDecimal.valueOf(1000));
|
|
|
- double totalWeight = todList.stream().mapToDouble(o -> o.getWeight().doubleValue()).sum();
|
|
|
TwinOrderDetail tod = todList.get(0);
|
|
|
|
|
|
BomVO bom = new BomVO();
|
|
|
@@ -198,7 +210,11 @@ public class OrderApiController extends BaseController {
|
|
|
twinOrder.setBomList(bomVOList);
|
|
|
twinOrder.setTwinOrderDetailList(null);
|
|
|
}
|
|
|
- return orderList;
|
|
|
+ List<GramMassDetail> list = infos.stream()
|
|
|
+ .sorted(Comparator.comparing(GramMassDetail::getSy).reversed())
|
|
|
+ .limit(10)
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ return success(orderList).put("list", list);
|
|
|
}
|
|
|
|
|
|
// @ApiOperation("按订单号查询预测信息")
|