set sequences out stock
sortie de stock
This commit is contained in:
@@ -57,6 +57,9 @@ import java.util.Optional;
|
|||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
import com.axelor.db.JPA;
|
||||||
|
import javax.persistence.Query;
|
||||||
|
import com.axelor.apps.base.service.app.AppBaseService;
|
||||||
|
|
||||||
@Singleton
|
@Singleton
|
||||||
public class StockMoveController {
|
public class StockMoveController {
|
||||||
@@ -576,4 +579,36 @@ public class StockMoveController {
|
|||||||
TraceBackService.trace(response, e);
|
TraceBackService.trace(response, e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//sortie de stock
|
||||||
|
public void getSequenceOutStock(ActionRequest request, ActionResponse response) {
|
||||||
|
Context context = request.getContext();
|
||||||
|
if(context.get("stockMoveSeq") == null){
|
||||||
|
String num;
|
||||||
|
int currentYear = Beans.get(AppBaseService.class).getTodayDateTime().getYear();
|
||||||
|
String[] splityear = Integer.toString(currentYear).split("20");
|
||||||
|
String year = splityear[1];
|
||||||
|
year ="SR"+year;
|
||||||
|
Query q =
|
||||||
|
JPA.em()
|
||||||
|
.createQuery(
|
||||||
|
" select stockMoveSeq from StockMove where stockMoveSeq like ?1 ORDER BY stockMoveSeq DESC",
|
||||||
|
String.class);
|
||||||
|
q.setParameter(1, year + "%" );
|
||||||
|
|
||||||
|
if (q.getResultList().size() == 0) {
|
||||||
|
response.setValue("stockMoveSeq", year+"00001");
|
||||||
|
} else {
|
||||||
|
String result = (String) q.getResultList().get(0);
|
||||||
|
String arr[] = result.split(year);
|
||||||
|
String nbrString = arr[1];
|
||||||
|
int nbrInt = Integer.parseInt(nbrString);
|
||||||
|
nbrInt = nbrInt + 1;
|
||||||
|
num = Integer.toString(nbrInt);
|
||||||
|
String padding = "00000".substring(num.length()) + num;
|
||||||
|
result = year + padding;
|
||||||
|
response.setValue("stockMoveSeq", result);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user