|
|
@@ -27,6 +27,7 @@ import javax.annotation.Resource;
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
import java.io.*;
|
|
|
import java.math.BigDecimal;
|
|
|
+import java.math.RoundingMode;
|
|
|
import java.net.URLEncoder;
|
|
|
import java.time.LocalDate;
|
|
|
import java.time.LocalDateTime;
|
|
|
@@ -154,7 +155,7 @@ public class OrderApiController extends BaseController {
|
|
|
//按设备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());
|
|
|
+ TwinCalcDay day = dayMap.get((long) info.getFormula_data_2());
|
|
|
double ycl = day.getWeight().multiply(BigDecimal.valueOf(days)).doubleValue();
|
|
|
info.setKcl(0d);
|
|
|
info.setYcl(ycl);
|
|
|
@@ -178,41 +179,49 @@ public class OrderApiController extends BaseController {
|
|
|
}
|
|
|
//匹配生产设备
|
|
|
List<GramMassDetail> matchFormula = oe.matchFormula(spec, infos);
|
|
|
+ List<GramMassDetail> deviceList = new ArrayList<>();
|
|
|
double totalWeight = todList.stream().mapToDouble(o -> o.getWeight().doubleValue()).sum();
|
|
|
BigDecimal cl = BigDecimal.ZERO;
|
|
|
+ BomVO bom = new BomVO();
|
|
|
+ TwinOrderDetail tod = todList.get(0);
|
|
|
+ bom.setBomCode(tod.getBomCode());
|
|
|
+ bom.setBomName(tod.getBomName());
|
|
|
+ bom.setBomSpec(spec);
|
|
|
for (GramMassDetail match : matchFormula) {
|
|
|
GramMassDetail gd = deviceMap.get(match.getFormula_data_2());
|
|
|
- TwinCalcDay day = dayMap.get((long)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.setKcl(BigDecimal.valueOf(kc).divide(BigDecimal.valueOf(1000), 1, RoundingMode.HALF_UP).doubleValue());
|
|
|
+ gd.setXql(BigDecimal.valueOf(totalWeight).divide(BigDecimal.valueOf(1000), 1, RoundingMode.HALF_UP).doubleValue());
|
|
|
gd.setSy();
|
|
|
+ deviceList.add(gd);
|
|
|
+ gd.setBomCode(tod.getBomCode());
|
|
|
+ gd.setBomName(tod.getBomName());
|
|
|
+ bom.setBomSpec(tod.getBomSpec());
|
|
|
}
|
|
|
|
|
|
cl = cl.multiply(BigDecimal.valueOf(1000));
|
|
|
- TwinOrderDetail tod = todList.get(0);
|
|
|
-
|
|
|
- BomVO bom = new BomVO();
|
|
|
bom.setLast(cl.doubleValue());
|
|
|
- bom.setBomCode(tod.getBomCode());
|
|
|
- bom.setBomName(tod.getBomName());
|
|
|
- bom.setBomSpec(spec);
|
|
|
bom.setXql(totalWeight);
|
|
|
bom.setKcl(kc);
|
|
|
double ycl = cl.multiply(BigDecimal.valueOf(days)).doubleValue();
|
|
|
double cz = totalWeight - kc - ycl;
|
|
|
bom.setYcl(ycl);
|
|
|
bom.setCz(cz);
|
|
|
+ bom.setDeviceList(deviceList);
|
|
|
bomVOList.add(bom);
|
|
|
}
|
|
|
twinOrder.setBomList(bomVOList);
|
|
|
twinOrder.setTwinOrderDetailList(null);
|
|
|
}
|
|
|
+
|
|
|
List<GramMassDetail> list = infos.stream()
|
|
|
- .sorted(Comparator.comparing(GramMassDetail::getSy).reversed())
|
|
|
- .limit(10)
|
|
|
+ .sorted(Comparator.comparing((GramMassDetail gd) -> gd.getKcl() - gd.getXql())
|
|
|
+ .thenComparing(GramMassDetail::getSy)
|
|
|
+ .reversed())
|
|
|
+ .limit(20)
|
|
|
.collect(Collectors.toList());
|
|
|
return success(orderList).put("list", list);
|
|
|
}
|