use of com.axelor.apps.supplychain.db.MrpLineType in project axelor-open-suite by axelor.
the class MrpServiceImpl method consolidateMrp.
protected void consolidateMrp() {
List<MrpLine> mrpLineList = mrpLineRepository.all().filter("self.mrp.id = ?1", mrp.getId()).order("product.code").order("maturityDate").order("mrpLineType.typeSelect").order("mrpLineType.sequence").order("id").fetch();
Map<List<Object>, MrpLine> map = Maps.newHashMap();
MrpLine consolidateMrpLine = null;
List<Object> keys = new ArrayList<>();
for (MrpLine mrpLine : mrpLineList) {
MrpLineType mrpLineType = mrpLine.getMrpLineType();
keys.clear();
keys.add(mrpLineType);
keys.add(mrpLine.getProduct());
keys.add(mrpLine.getMaturityDate());
keys.add(mrpLine.getStockLocation());
if (map.containsKey(keys)) {
consolidateMrpLine = map.get(keys);
consolidateMrpLine.setQty(consolidateMrpLine.getQty().add(mrpLine.getQty()));
consolidateMrpLine.setCumulativeQty(consolidateMrpLine.getCumulativeQty().add(mrpLine.getCumulativeQty()));
mrpLineRepository.remove(mrpLine);
} else {
map.put(keys, mrpLine);
}
}
}
use of com.axelor.apps.supplychain.db.MrpLineType in project axelor-open-suite by axelor.
the class MrpServiceProductionImpl method createMPSLines.
protected void createMPSLines() throws AxelorException {
MrpLineType mpsNeedMrpLineType = this.getMrpLineType(MrpLineTypeRepository.ELEMENT_MASTER_PRODUCTION_SCHEDULING);
if (mpsNeedMrpLineType == null || mrp.getMrpTypeSelect() != MrpRepository.MRP_TYPE_MRP) {
return;
}
List<MrpLine> mpsMrpLineList = mrpLineRepository.all().filter("self.product.id in (?1) AND self.stockLocation in (?2) AND self.mrp.mrpTypeSelect = ?3 " + "AND self.mrp.statusSelect = ?4 AND self.mrpLineType.elementSelect = ?5 AND self.maturityDate >= ?6 AND (?7 is true OR self.maturityDate <= ?8)", this.productMap.keySet(), this.stockLocationList, MrpRepository.MRP_TYPE_MPS, MrpRepository.STATUS_CALCULATION_ENDED, MrpLineTypeRepository.ELEMENT_MASTER_PRODUCTION_SCHEDULING, today.atStartOfDay(), mrp.getEndDate() == null, mrp.getEndDate()).fetch();
for (MrpLine mpsMrpLine : mpsMrpLineList) {
this.createMpsMrpLines(mrpRepository.find(mrp.getId()), mrpLineRepository.find(mpsMrpLine.getId()), mrpLineTypeRepository.find(mpsNeedMrpLineType.getId()));
JPA.clear();
}
}
use of com.axelor.apps.supplychain.db.MrpLineType in project axelor-open-suite by axelor.
the class MrpServiceProductionImpl method createManufOrderMrpLines.
// Manufacturing order AND manufacturing order need
protected void createManufOrderMrpLines() throws AxelorException {
MrpLineType manufOrderMrpLineType = this.getMrpLineType(MrpLineTypeRepository.ELEMENT_MANUFACTURING_ORDER);
if (manufOrderMrpLineType == null) {
return;
}
MrpLineType manufOrderNeedMrpLineType = this.getMrpLineType(MrpLineTypeRepository.ELEMENT_MANUFACTURING_ORDER_NEED);
String statusSelect = manufOrderMrpLineType.getStatusSelect();
List<Integer> statusList = StringTool.getIntegerList(statusSelect);
if (statusList.isEmpty()) {
statusList.add(ManufOrderRepository.STATUS_FINISHED);
}
List<ManufOrder> manufOrderList = manufOrderRepository.all().filter("self.product.id in (?1) AND self.prodProcess.stockLocation in (?2) " + "AND self.statusSelect IN (?3)", this.productMap.keySet(), this.stockLocationList, statusList).fetch();
for (ManufOrder manufOrder : manufOrderList) {
this.createManufOrderMrpLines(mrpRepository.find(mrp.getId()), manufOrderRepository.find(manufOrder.getId()), mrpLineTypeRepository.find(manufOrderMrpLineType.getId()), mrpLineTypeRepository.find(manufOrderNeedMrpLineType.getId()));
JPA.clear();
}
}
use of com.axelor.apps.supplychain.db.MrpLineType in project axelor-open-suite by axelor.
the class MrpServiceProductionImpl method createProposalMrpLine.
@Override
@Transactional(rollbackOn = { Exception.class })
protected void createProposalMrpLine(Mrp mrp, Product product, MrpLineType mrpLineType, BigDecimal reorderQty, StockLocation stockLocation, LocalDate maturityDate, List<MrpLineOrigin> mrpLineOriginList, String relatedToSelectName) throws AxelorException {
super.createProposalMrpLine(mrp, product, mrpLineType, reorderQty, stockLocation, maturityDate, mrpLineOriginList, relatedToSelectName);
if (!Beans.get(AppProductionService.class).isApp("production")) {
return;
}
BillOfMaterial defaultBillOfMaterial = product.getDefaultBillOfMaterial();
if (mrpLineType.getElementSelect() == MrpLineTypeRepository.ELEMENT_MANUFACTURING_PROPOSAL && defaultBillOfMaterial != null) {
MrpLineType manufProposalNeedMrpLineType = this.getMrpLineType(MrpLineTypeRepository.ELEMENT_MANUFACTURING_PROPOSAL_NEED);
if (manufProposalNeedMrpLineType == null) {
return;
}
for (BillOfMaterial billOfMaterial : defaultBillOfMaterial.getBillOfMaterialSet()) {
Product subProduct = billOfMaterial.getProduct();
if (this.isMrpProduct(subProduct)) {
// TODO take the time to do the Manuf order (use machine planning)
super.createProposalMrpLine(mrp, subProduct, manufProposalNeedMrpLineType, reorderQty.multiply(billOfMaterial.getQty()).setScale(appBaseService.getNbDecimalDigitForQty(), RoundingMode.HALF_UP), stockLocation, maturityDate, mrpLineOriginList, relatedToSelectName);
}
}
}
}
Aggregations