|
|
@@ -6,12 +6,15 @@ import com.huaweicloud.sdk.lts.v2.model.SqlAlarmRuleRespList;
|
|
|
import common.Controller;
|
|
|
import common.YosException;
|
|
|
import common.annotation.API;
|
|
|
+import common.annotation.Param;
|
|
|
import common.data.*;
|
|
|
import io.swagger.annotations.Api;
|
|
|
import org.apache.camel.json.simple.Jsonable;
|
|
|
import restcontroller.R;
|
|
|
|
|
|
+import java.lang.reflect.Field;
|
|
|
import java.util.ArrayList;
|
|
|
+import java.util.HashMap;
|
|
|
|
|
|
/**
|
|
|
* 定制费用方案
|
|
|
@@ -198,11 +201,92 @@ public class OrderFeeCostPlan extends Controller {
|
|
|
Long status = content.getLongValue("status");
|
|
|
UpdateSQL updateSQL = SQLFactory.createUpdateSQL(this, "sys_datafunction");
|
|
|
updateSQL.setUniqueid(sys_datafunctionid);
|
|
|
- updateSQL.setValue("status", status==1?"启用":"禁用");
|
|
|
+ updateSQL.setValue("status", status == 1 ? "启用" : "禁用");
|
|
|
updateSQL.update();
|
|
|
|
|
|
|
|
|
return getSucReturnObject().toString();
|
|
|
}
|
|
|
|
|
|
+ @API(title = "新增或修改方案", apiversion = R.ID20231225141902.v1.class)
|
|
|
+ public String insertormodifyFunction() throws YosException {
|
|
|
+ long sys_datafunctionid = content.getLong("sys_datafunctionid");
|
|
|
+ String classname = content.getString("classname");
|
|
|
+ String remarks = content.getString("remarks");
|
|
|
+
|
|
|
+
|
|
|
+ HashMap<String, Param> sys_paramMap = new HashMap<>();
|
|
|
+ if (!classname.equals("")) {
|
|
|
+ try {
|
|
|
+ Class<?> clz = Class.forName("function." + classname);
|
|
|
+ for (Field field : clz.getDeclaredFields()) {
|
|
|
+ if (field.isAnnotationPresent(Param.class)) {
|
|
|
+ sys_paramMap.put(field.getName(), field.getAnnotation(Param.class));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ return getErrReturnObject().setErrMsg("无效的执行类" + classname).toString();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ if (sys_datafunctionid <= 0 || dbConnect.runSqlQuery("select * from sys_datafunction where sys_datafunctionid=" + sys_datafunctionid).isEmpty()) {
|
|
|
+ sys_datafunctionid = createTableID("sys_datafunction");
|
|
|
+ InsertSQL insertSQL = SQLFactory.createInsertSQL(this, "sys_datafunction");
|
|
|
+ insertSQL.setValue("sys_datafunctionid", sys_datafunctionid);
|
|
|
+ insertSQL.setValue("functionname", createBillCode("dfnum"));
|
|
|
+ insertSQL.setValue("type", "update");
|
|
|
+ insertSQL.setValue("classname", classname);
|
|
|
+ insertSQL.setValue("remarks", remarks);
|
|
|
+ insertSQL.setValue("datakey", "default");
|
|
|
+ insertSQL.setValue("functionclass", "ordercost");
|
|
|
+ insertSQL.insert();
|
|
|
+
|
|
|
+ } else {
|
|
|
+ UpdateSQL rowUpdate = SQLFactory.createUpdateSQL(this, "sys_datafunction");
|
|
|
+ rowUpdate.setValue("remarks", remarks);
|
|
|
+ rowUpdate.setValue("classname", classname);
|
|
|
+ rowUpdate.setValue("functionclass", "ordercost");
|
|
|
+ rowUpdate.setWhere("sys_datafunctionid", sys_datafunctionid);
|
|
|
+ rowUpdate.update();
|
|
|
+ }
|
|
|
+
|
|
|
+ ArrayList<String> ps = new ArrayList<>();
|
|
|
+ ArrayList<String> paramSqlList = new ArrayList<>();
|
|
|
+ //获取执行函数的参数
|
|
|
+ for (String sys_param : sys_paramMap.keySet()) {
|
|
|
+ ps.add(sys_param);
|
|
|
+ Param param = sys_paramMap.get(sys_param);
|
|
|
+ if (dbConnect.runSqlQuery("select *from sys_datafunction_params where sys_datafunctionid=" + sys_datafunctionid + " and param='" + sys_param + "'").isEmpty()) {
|
|
|
+ InsertSQL insertSQL = SQLFactory.createInsertSQL(this, "sys_datafunction_params");
|
|
|
+ insertSQL.setValue("sys_datafunctionid", sys_datafunctionid);
|
|
|
+ insertSQL.setValue("param", sys_param);
|
|
|
+ if (sys_param.equals("siteid")) {
|
|
|
+ insertSQL.setValue("value", siteid);
|
|
|
+ }
|
|
|
+ insertSQL.setValue("paramname", param.paramname());
|
|
|
+ insertSQL.setValue("remarks", param.remarks());
|
|
|
+ insertSQL.setValue("issystem", param.issystem());
|
|
|
+ paramSqlList.add(insertSQL.getSQL());
|
|
|
+ } else {
|
|
|
+ UpdateSQL updateSQL = SQLFactory.createUpdateSQL(this, "sys_datafunction_params");
|
|
|
+ updateSQL.setValue("paramname", param.paramname());
|
|
|
+ updateSQL.setValue("issystem", param.issystem());
|
|
|
+ updateSQL.setWhere("sys_datafunctionid", sys_datafunctionid).setWhere("param", param).setWhere("ifnull(paramname,'')=''");
|
|
|
+ paramSqlList.add(updateSQL.getSQL());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ /*
|
|
|
+ 删除多余的参数
|
|
|
+ */
|
|
|
+ DeleteSQL deleteSQL = SQLFactory.createDeleteSQL(this, "sys_datafunction_params");
|
|
|
+ deleteSQL.setWhere("sys_datafunctionid", sys_datafunctionid);
|
|
|
+ deleteSQL.setWhere("param not in $params$");
|
|
|
+ deleteSQL.addParameter("params", ps);
|
|
|
+ paramSqlList.add(deleteSQL.getSQL());
|
|
|
+
|
|
|
+ dbConnect.runSqlUpdate(paramSqlList);
|
|
|
+ return getSucReturnObject().toString();
|
|
|
+ }
|
|
|
+
|
|
|
}
|