This commit is contained in:
2024-08-22 19:56:51 +08:00
parent 839b79a4cb
commit 42752f3085
3 changed files with 31 additions and 3 deletions

View File

@@ -51,6 +51,11 @@ public class EmpSalaryItemController {
return R.success(this.service.genScript(Ctx.currentUser().getOrganizationId()));
}
@PostMapping("/genScriptWithCompileResult")
public Object genScriptWithCompileResult() {
return R.success(this.service.genScriptWithCompileResult(Ctx.currentUser().getOrganizationId()));
}
@PostMapping("/init")
public Object init() {
this.service.initOrg(Ctx.currentUser().getOrganizationId());

View File

@@ -1,5 +1,6 @@
package cn.lihongjie.coal.empSalaryItem.service;
import cn.hutool.core.exceptions.ExceptionUtil;
import cn.lihongjie.coal.base.dto.CommonQuery;
import cn.lihongjie.coal.base.dto.IdRequest;
import cn.lihongjie.coal.base.service.BaseService;
@@ -657,6 +658,28 @@ public class EmpSalaryItemService
repository.save(item3);
}
public Object genScriptWithCompileResult(String organizationId) {
String script = genScript(organizationId);
Exception exception = null;
try {
groovyScriptManager.compile(script);
} catch (Exception e) {
exception = e;
}
return Map.of(
"script",
script,
"error",
exception != null,
"exception",
exception == null ? "" : ExceptionUtil.stacktraceToString(exception));
}
public String genScript(String organizationId) {
List<EmpSalaryItemEntity> items =

View File

@@ -28,7 +28,7 @@ INSERT INTO t_emp_salary_sys_item (id, create_time, create_user_id, file_ids, up
scale = scale ?: 2
mode = mode ?: 0
def d = BigDecimal.valueOf(Double.valueOf(val + "").doubleValue()).stripTrailingZeros() on conflict (id) do nothing;
def d = BigDecimal.valueOf(Double.valueOf(val + "").doubleValue()).stripTrailingZeros();
if (d.scale() <= scale) {
return d
}
@@ -262,7 +262,7 @@ INSERT INTO t_emp_salary_sys_item (id, create_time, create_user_id, file_ids, up
for (int i = 0 on conflict (id) do nothing; i < y.size() on conflict (id) do nothing; i += 2) {
for (int i = 0 ; i < y.size() ; i += 2) {
if (x == y[i]) {
return y[i + 1]
}
@@ -298,7 +298,7 @@ INSERT INTO t_emp_salary_sys_item (id, create_time, create_user_id, file_ids, up
def TABLE(def... y){
for (int i = 0 on conflict (id) do nothing; i < y.size() on conflict (id) do nothing; i += 2) {
for (int i = 0 ; i < y.size() ; i += 2) {
if (y[i]) {
return y[i + 1]
}