|
|
@@ -0,0 +1,106 @@
|
|
|
+package com.awspaas.user.apps.donenow_ivt.event;
|
|
|
+
|
|
|
+import com.actionsoft.bpms.bo.engine.BO;
|
|
|
+import com.actionsoft.bpms.bpmn.engine.core.delegate.ProcessExecutionContext;
|
|
|
+import com.actionsoft.bpms.bpmn.engine.listener.ListenerConst;
|
|
|
+import com.actionsoft.bpms.bpmn.engine.listener.ValueListener;
|
|
|
+import com.actionsoft.bpms.commons.mvc.view.ResponseObject;
|
|
|
+import com.actionsoft.bpms.util.DBSql;
|
|
|
+import com.actionsoft.sdk.local.SDK;
|
|
|
+import com.alibaba.fastjson.JSONArray;
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
+
|
|
|
+import java.sql.Connection;
|
|
|
+import java.sql.SQLException;
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.HashMap;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+
|
|
|
+public class productCancle extends ValueListener {
|
|
|
+ /**
|
|
|
+ * 产品注销
|
|
|
+ * @param ctx
|
|
|
+ * @return
|
|
|
+ * @throws Exception
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public String execute(ProcessExecutionContext ctx) {
|
|
|
+ //参数获取
|
|
|
+ //记录ID
|
|
|
+ String boId = ctx.getParameterOfString(ListenerConst.FORM_EVENT_PARAM_BOID);
|
|
|
+ //表单ID
|
|
|
+ String formId = ctx.getParameterOfString(ListenerConst.FORM_EVENT_PARAM_FORMID);
|
|
|
+ //BO表名
|
|
|
+ String boName = ctx.getParameterOfString(ListenerConst.FORM_EVENT_PARAM_BONAME);
|
|
|
+ //视图场景获取选中行数据
|
|
|
+ String rowData = ctx.getParameterOfString("$SOURCEDATA");
|
|
|
+ // Ajax方式
|
|
|
+ ResponseObject ro = ResponseObject.newOkResponse();
|
|
|
+ boolean r = true;// 针对业务进行处理
|
|
|
+ System.out.println("productCancle");
|
|
|
+ System.out.println("产品注销");
|
|
|
+ System.out.println("boId:" + boId);
|
|
|
+ System.out.println("formId:" + formId);
|
|
|
+ System.out.println("boName:" + boName);
|
|
|
+ System.out.println("rowData:" + rowData);
|
|
|
+
|
|
|
+ List<String> productIds = new ArrayList<>();
|
|
|
+
|
|
|
+ if (StringUtils.isNotBlank(boId)) productIds.add(boId);
|
|
|
+
|
|
|
+
|
|
|
+ if (StringUtils.isNotBlank(rowData)) {
|
|
|
+ JSONObject rowDataJson = JSONObject.parseObject(rowData);
|
|
|
+ JSONArray data = rowDataJson.getJSONArray("data");
|
|
|
+ if ((data.size() > 0)) for (int i = 0; i < data.size(); i++) {
|
|
|
+ JSONObject jsonObject = data.getJSONObject(i);
|
|
|
+ productIds.add(jsonObject.getString("_ID"));
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (productIds.size() == 0) {
|
|
|
+ ro.msg("请选择注销产品");
|
|
|
+ return ro.toString();
|
|
|
+ }
|
|
|
+ System.out.println("productIds:" + productIds);
|
|
|
+ Connection conn = null;
|
|
|
+ try {
|
|
|
+ conn = DBSql.open();
|
|
|
+ conn.setAutoCommit(false);
|
|
|
+ for (String productId : productIds) {
|
|
|
+ BO bo = SDK.getBOAPI().get("BO_EU_DNIVT_PRODUCT", productId);
|
|
|
+ bo.set("CLOSED", 1);
|
|
|
+ Map<String, Object> params = new HashMap<>();
|
|
|
+ params.put("ID", productId);
|
|
|
+ params.put("CLOSED", 1);
|
|
|
+ dn.recordFormChanges.record(ctx.getUserContext(), "BO_EU_DNIVT_PRODUCT", params, "注销");//记录操作日志
|
|
|
+ SDK.getBOAPI().update("BO_EU_DNIVT_PRODUCT", bo);
|
|
|
+ }
|
|
|
+ conn.commit();
|
|
|
+ } catch (SQLException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ try {
|
|
|
+ conn.rollback();
|
|
|
+ } catch (SQLException ex) {
|
|
|
+ r = false;
|
|
|
+ }
|
|
|
+ } finally {
|
|
|
+ if (conn != null)
|
|
|
+ DBSql.close(conn);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 处理业务逻辑成功时
|
|
|
+ if (r) {
|
|
|
+ ro.msg("成功");// 返回给服务器的消息
|
|
|
+ // ro.put("key1", "value1").put("key2", "value2");// 放入前端需要的参数
|
|
|
+ return ro.toString();
|
|
|
+ } else {
|
|
|
+ // 错误时
|
|
|
+ ro = ResponseObject.newErrResponse();
|
|
|
+ ro.msg("错误");
|
|
|
+ return ro.toString();
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|