From 25dea452f177add2a3aed7553e0d9bbfd4e65692 Mon Sep 17 00:00:00 2001 From: "zakaria.hachem" Date: Tue, 5 Nov 2024 13:53:22 +0100 Subject: [PATCH] add : QvmOperationController.java --- .../apps.qvm/web/QvmOperationController.java | 103 ++++++++++++++++++ 1 file changed, 103 insertions(+) create mode 100644 modules/axelor-open-suite/axelor-qvm/src/main/java/com.axelor/apps.qvm/web/QvmOperationController.java diff --git a/modules/axelor-open-suite/axelor-qvm/src/main/java/com.axelor/apps.qvm/web/QvmOperationController.java b/modules/axelor-open-suite/axelor-qvm/src/main/java/com.axelor/apps.qvm/web/QvmOperationController.java new file mode 100644 index 00000000..dd75f2c5 --- /dev/null +++ b/modules/axelor-open-suite/axelor-qvm/src/main/java/com.axelor/apps.qvm/web/QvmOperationController.java @@ -0,0 +1,103 @@ +/* + * Axelor Business Solutions + * + * Copyright (C) 2019 Axelor (). + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License, version 3, + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ +package com.axelor.apps.qvm.web; + +import com.axelor.apps.qvm.db.Operation; +import com.axelor.apps.qvm.service.OperationService; +import com.axelor.apps.qvm.service.OperationServiceImpl; +import com.axelor.exception.AxelorException; +import com.axelor.exception.service.TraceBackService; +import com.axelor.inject.Beans; +import com.axelor.rpc.ActionRequest; +import com.axelor.rpc.ActionResponse; +import com.google.inject.Singleton; +import java.lang.invoke.MethodHandles; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class QvmOperationController { + + private final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass()); + + public void setSequenceOperation(ActionRequest request, ActionResponse response) { + try { + Operation calibration = request.getContext().asType(Operation.class); + + if (calibration != null && calibration.getCompany() != null) { + response.setValue( + "serialNumber", + Beans.get(OperationService.class) + .createOperationSeq(calibration.getCompany()) + .getSerialNumber()); + } else { + System.out.println("Operation or company est null"); + System.out.println("Operation : " + calibration); + System.out.println("Company : " + calibration.getCompany()); + } + } catch (Exception e) { + TraceBackService.trace(response, e); + } + } + + public void setSequenceCalibration(ActionRequest request, ActionResponse response) { + try { + Operation calibration = request.getContext().asType(Operation.class); + + if (calibration != null && calibration.getCompany() != null) { + response.setValue( + "serialNumber", + Beans.get(OperationService.class) + .createCalibrationSeq(calibration.getCompany()) + .getSerialNumber()); + } else { + System.out.println("Operation or company est null"); + System.out.println("Operation : " + calibration); + System.out.println("Company : " + calibration.getCompany()); + } + } catch (Exception e) { + TraceBackService.trace(response, e); + } + } + + public void setSequenceQualification(ActionRequest request, ActionResponse response) { + try { + Operation calibration = request.getContext().asType(Operation.class); + + if (calibration != null && calibration.getCompany() != null) { + response.setValue( + "serialNumber", + Beans.get(OperationService.class) + .createQualificationSeq(calibration.getCompany()) + .getSerialNumber()); + } else { + System.out.println("Operation or company est null"); + System.out.println("Operation : " + calibration); + System.out.println("Company : " + calibration.getCompany()); + } + } catch (Exception e) { + TraceBackService.trace(response, e); + } + } + + public void setMachineInfo(ActionRequest request, ActionResponse response) + throws AxelorException { + Operation calibration = request.getContext().asType(Operation.class); + Operation newOperation = Beans.get(OperationService.class).setMachine(calibration); + // response.setValue(calibration,newOperation); + } +}