Просмотр исходного кода

1、库存删除功能校验
2、取消配送,删除关联的生成运费成本;
3、配送生成生成运费成本;

zhangyao 4 месяцев назад
Родитель
Сommit
4c9666e5a1

BIN
com.awspaas.user.apps.donenow_crm/lib/com.awspaas.user.apps.donenow_crm.jar


BIN
com.awspaas.user.apps.donenow_crm/lib/com.awspaas.user.apps.donenow_crm2.jar


+ 46 - 0
com.awspaas.user.apps.donenow_crm/src/com/awspaas/user/apps/donenow_crm/event/InstalledProductFormBeforeSave.java

@@ -0,0 +1,46 @@
+package com.awspaas.user.apps.donenow_crm.event;
+
+import com.actionsoft.bpms.bo.engine.BO;
+import com.actionsoft.bpms.bpmn.engine.core.delegate.ProcessExecutionContext;
+import com.actionsoft.bpms.bpmn.engine.listener.InterruptListener;
+import com.actionsoft.bpms.bpmn.engine.listener.ListenerConst;
+import com.actionsoft.bpms.server.UserContext;
+import com.actionsoft.bpms.util.DBSql;
+import com.actionsoft.sdk.local.SDK;
+import org.apache.commons.lang3.StringUtils;
+
+public class InstalledProductFormBeforeSave extends InterruptListener {
+    public String getDescription() {
+        return "配置项保存前事件";
+    }
+
+    /**
+     *配置项保存前事件
+     * @param processExecutionContext
+     * @return
+     * @throws Exception
+     */
+    @Override
+    public boolean execute(ProcessExecutionContext processExecutionContext) throws Exception {
+        UserContext uc = processExecutionContext.getUserContext();
+        String boId = processExecutionContext.getParameterOfString(ListenerConst.FORM_EVENT_PARAM_BOID);
+        BO formData = processExecutionContext.getFormData();
+        String boName = processExecutionContext.getParameterOfString("$BONAME");
+        String bindId = processExecutionContext.getProcessInstance().getId();
+        boolean isCreate = processExecutionContext.getParameterOfBoolean(ListenerConst.FORM_EVENT_PARAM_ISCREATE);
+        String CONTRACT_COST_ID1 = formData.getString("CONTRACT_COST_ID");
+        if (StringUtils.isNotBlank(boId)) {
+            Object CONTRACT_COST_ID2 = SDK.getBOAPI().get(boName, boId, "CONTRACT_COST_ID");
+            if (CONTRACT_COST_ID2 != null) {
+                DBSql.update("update BO_EU_DNCTT_CONTRACT_COST set CREATE_CI=0 where ID=?", new Object[]{CONTRACT_COST_ID2});
+            }
+        }
+
+        if (StringUtils.isNotBlank(CONTRACT_COST_ID1))
+            DBSql.update("update BO_EU_DNCTT_CONTRACT_COST set CREATE_CI=1 where ID=?", new Object[]{CONTRACT_COST_ID1});
+
+        //记录表单修改
+        dn.recordFormChanges.execute(processExecutionContext);
+        return true;
+    }
+}

BIN
com.awspaas.user.apps.donenow_ctt/lib/com.awspaas.user.apps.donenow_ctt.jar


+ 14 - 4
com.awspaas.user.apps.donenow_ctt/src/com/awspaas/user/apps/donenow_ctt/event/costProductShipFormAfterSave.java

@@ -198,10 +198,17 @@ public class costProductShipFormAfterSave extends ExecuteListener {
                 //生成运费成本
                 // 输入运费的物料计费代码,就会生成新的成本ctt_contract_cost
                 if (StringUtils.isNotBlank(productBO.getString("COST_CODE_ID"))) {
+                    BO costShipBO = null;
+                    ProcessInstance costShipProcessIns = null;
+                    if (StringUtils.isNotBlank(productBO.getString("SHIPPING_CONTRACT_COST_ID"))) {
+                        costShipProcessIns = SDK.getProcessAPI().createBOProcessInstance("obj_87c6ef75d18f44cc8e85d3d4e818c303", processExecutionContext.getUserContext().getUID(), "合同产品-生成运费成本");
+                        costShipBO = new BO();
+                        costShipBO.setBindId(costShipProcessIns.getId());
+                    } else {
+                        costShipBO = SDK.getBOAPI().get("BO_EU_DNCTT_CONTRACT_COST", productBO.getString("SHIPPING_CONTRACT_COST_ID"));
+                        costShipBO.set("CLOSED", 0);
+                    }
 
-                    ProcessInstance costShipProcessIns = SDK.getProcessAPI().createBOProcessInstance("obj_87c6ef75d18f44cc8e85d3d4e818c303", processExecutionContext.getUserContext().getUID(), "合同产品-生成运费成本");
-                    BO costShipBO = new BO();
-                    costShipBO.setBindId(costShipProcessIns.getId());
                     costShipBO.set("PRODUCT_ID", null);
                     costShipBO.set("CONTRACT_ID", costBO.get("CONTRACT_ID"));
                     costShipBO.set("COST_CODE_ID", productBO.get("COST_CODE_ID"));
@@ -222,7 +229,10 @@ public class costProductShipFormAfterSave extends ExecuteListener {
                     costShipBO.set("ACCOUNT_ID", costBO.get("ACCOUNT_ID"));
                     costShipBO.set("BILL_ACCOUNT_ID", costBO.get("BILL_ACCOUNT_ID"));
 
-                    SDK.getBOAPI().create("BO_EU_DNCTT_CONTRACT_COST", costShipBO, costShipProcessIns, processExecutionContext.getUserContext(), conn);
+                    if (costShipProcessIns != null)
+                        SDK.getBOAPI().create("BO_EU_DNCTT_CONTRACT_COST", costShipBO, costShipProcessIns, processExecutionContext.getUserContext(), conn);
+                    else
+                        SDK.getBOAPI().update("BO_EU_DNCTT_CONTRACT_COST", costShipBO, conn);
 
                     //关联产品成本
                     DBSql.update(conn, "update BO_EU_DNCTT_CONTRACT_COST_PRODUCT set SHIPPING_CONTRACT_COST_ID=? where ID=?", new Object[]{costShipBO.getId(), productBO.getId()});

BIN
com.awspaas.user.apps.donenow_ivt/lib/com.awspaas.user.apps.donenow_ivt.jar


+ 25 - 0
com.awspaas.user.apps.donenow_ivt/src/com/awspaas/user/apps/donenow_ivt/controller/IVTController.java

@@ -353,4 +353,29 @@ public class IVTController extends BaseController {
         url = SDK.getPortalAPI().getPortalUrl() + "/r" + url.substring(1);
         return url;
     }
+
+    /**
+     * 删除库存
+     * @param uc
+     * @param bindId
+     * @return
+     */
+    @Mapping("com.awspaas.user.apps.donenow_ivt.warehouse_product_del")
+    public String warehouseProductDel(UserContext uc, String bindId) {
+        if (org.apache.commons.lang3.StringUtils.isBlank(bindId))
+            return fail("请选择要删除的行");
+        BO bo = SDK.getBOAPI().query(IVTConstant.BO_EU_DNIVT_WAREHOUSE_PRODUCT).bindId(bindId).detail();
+        if (null == bo)
+            return fail("未找到对应的行");
+
+        if (bo.getString("QUANTITY").equals("0") == false)
+            return fail("库存数量不为零,不能删除!");
+
+        SDK.getBOAPI().removeByBindId(IVTConstant.BO_EU_DNIVT_WAREHOUSE_PRODUCT, bo.getBindId());
+        SDK.getBOAPI().removeByBindId(IVTConstant.BO_EU_DNIVT_WAREHOUSE_PRODUCT_LOT, bindId);
+
+        return success("删除成功!");
+    }
+
+
 }

+ 7 - 1
com.awspaas.user.apps.donenow_ivt/src/com/awspaas/user/apps/donenow_ivt/controller/ivtOrderController.java

@@ -256,7 +256,7 @@ public class ivtOrderController {
         if (StringUtils.isBlank(costPdtIds))
             return ResponseObject.newErrResponse("无数据");
 
-        List<RowMap> pdtList = DBSql.getMaps("select ID,STATUS_ID,CONTRACT_COST_ID,QUANTITY,WAREHOUSE_ID,SN from bo_eu_dnctt_contract_cost_product where FIND_IN_SET(ID,?)", new Object[]{costPdtIds});
+        List<RowMap> pdtList = DBSql.getMaps("select ID,STATUS_ID,CONTRACT_COST_ID,QUANTITY,WAREHOUSE_ID,SN,SHIPPING_CONTRACT_COST_ID from bo_eu_dnctt_contract_cost_product where FIND_IN_SET(ID,?)", new Object[]{costPdtIds});
 
         if (pdtList.isEmpty())
             return ResponseObject.newErrResponse("无数据");
@@ -343,7 +343,13 @@ public class ivtOrderController {
                     SDK.getBOAPI().update("BO_EU_DNIVT_WAREHOUSE_PRODUCT", lctPdtBO, conn);
                 }
 
+                //删除
+                if (StringUtils.isNotBlank(pdtMap.getString("SHIPPING_CONTRACT_COST_ID")))
+                    DBSql.update(conn, "update BO_EU_DNCTT_CONTRACT_COST_PRODUCT set CLOSED=1 where ID=?", new Object[]{pdtMap.getString("SHIPPING_CONTRACT_COST_ID")});
+               // DBSql.update(conn, "update BO_EU_DNCTT_CONTRACT_COST_PRODUCT set SHIPPING_CONTRACT_COST_ID=NULL where ID=?", new Object[]{pdtMap.getString("ID")});
             }
+
+
             conn.commit();
         } catch (SQLException e) {
             conn.rollback();

+ 3 - 9
com.awspaas.user.apps.donenow_ivt/src/com/awspaas/user/apps/donenow_ivt/event/ivtOrderProcessAfterComplete.java

@@ -29,7 +29,7 @@ public class ivtOrderProcessAfterComplete extends ExecuteListener {
         UserContext uc = processExecutionContext.getUserContext();
 
         BO purchaseOrder = SDK.getBOAPI().getByProcess("BO_EU_DNIVT_ORDER", BINDID);
-        purchaseOrder.set("STATUS_ID", "2148");//已提交
+        purchaseOrder.set("STATUS_ID", "2152");//采购中
         SDK.getBOAPI().update("BO_EU_DNIVT_ORDER", purchaseOrder);
 
         List<BO> orderProducts = SDK.getBOAPI().query("BO_EU_DNIVT_ORDER_PRODUCT").bindId(BINDID).list();
@@ -63,16 +63,10 @@ public class ivtOrderProcessAfterComplete extends ExecuteListener {
                 costProduct.set("SN", DBSql.getString("SELECT GROUP_CONCAT(SN) FROM BO_EU_DNIVT_WAREHOUSE_PRODUCT_LOT WHERE ORDER_PRODUCT_ID=?", new Object[]{costProduct.getId()}));
                 costProduct.set("OLD_QUANTITY", costProduct.get("QUANTITY"));//配送数量
 
-                try {
-                    //记录日志
-                    dn.recordFormChanges.record(uc, costProduct, "采购产品审批后新增");
-                } catch (Exception e) {
-
-                }
-
+                costProduct.set("SHIPPING_TYPE_ID", null);
+                dn.recordFormChanges.record(uc, costProduct, "采购产品审批后新增");
                 SDK.getBOAPI().create("BO_EU_DNCTT_CONTRACT_COST_PRODUCT", costProduct, processInstance, uc);
 
-
                 //已完成拣货或者在采购中
 
                 //仍需数量:

+ 16 - 4
com.awspaas.user.apps.donenow_ivt/src/com/awspaas/user/apps/donenow_ivt/event/productCancle.java

@@ -40,7 +40,7 @@ public class productCancle extends ValueListener {
         ResponseObject ro = ResponseObject.newOkResponse();
         boolean r = true;// 针对业务进行处理
         System.out.println("productCancle");
-        System.out.println("产品注销");
+        System.out.println("注销");
         System.out.println("boId:" + boId);
         System.out.println("formId:" + formId);
         System.out.println("boName:" + boName);
@@ -56,7 +56,12 @@ public class productCancle extends ValueListener {
             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"));
+                String productId = jsonObject.getString("_ID");
+                //如果最后两个字符是 _0/_1... 则去掉
+                if (productId.substring(productId.length() - 2, productId.length() - 1).equals("_")) {
+                    productId = productId.substring(0, productId.length() - 2);
+                }
+                productIds.add(productId);
             }
         }
 
@@ -71,12 +76,15 @@ public class productCancle extends ValueListener {
             conn.setAutoCommit(false);
             for (String productId : productIds) {
                 BO bo = SDK.getBOAPI().get("BO_EU_DNIVT_PRODUCT", productId);
+                if (bo == null) {
+                    throw new Exception("产品不存在");
+                }
                 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);
+                dn.recordFormChanges.record(ctx.getUserContext(), "BO_EU_DNIVT_PRODUCT", params, "注销", conn);//记录操作日志
+                SDK.getBOAPI().update("BO_EU_DNIVT_PRODUCT", bo, conn);
             }
             conn.commit();
         } catch (SQLException e) {
@@ -86,6 +94,10 @@ public class productCancle extends ValueListener {
             } catch (SQLException ex) {
                 r = false;
             }
+        } catch (Exception e) {
+            ro = ResponseObject.newErrResponse();
+            ro.msg("错误" + e.getMessage());
+            return ro.toString();
         } finally {
             if (conn != null)
                 DBSql.close(conn);

+ 4 - 2
com.awspaas.user.apps.donenow_sys/src/com/awspaas/user/apps/donenow_sys/controller/udfController.java

@@ -322,6 +322,7 @@ public class udfController {
 
 
     private static final String[] OBJECT_COL_NAME = new String[]{"ACCOUNT_ID", "CONTACT_ID", "CONTRACT_ID", "OPPORTUNITY_ID", "TICKET_ID", "TASK_ID", "SALES_ORDER_ID"};
+    private final String[] excludesArray = new String[]{"ID", "ORGID", "BINDID", "CREATEDATE", "CREATEUSER", "UPDATEDATE", "UPDATEUSER"};
 
     /**
      * 信息流组件上的自定义字段保存
@@ -393,9 +394,10 @@ public class udfController {
                 activityBo.set(objectColName, boMap.get(objectColName));
             }
         }
+
         activityBo.set("OBJECT_ID", boId);
 
-        switch (boDefName) {
+        switch (tableName) {
             case "BO_EU_DNCRM_ACCOUNT"://客户
                 activityBo.set("ACCOUNT_ID", boId);
                 activityBo.set("OBJECT_TYPE_ID", 735);
@@ -423,7 +425,7 @@ public class udfController {
         if (json.containsKey("NETWORK_CATE_ID"))
             activityBo.set("CATE_ID", json.getString("NETWORK_CATE_ID"));
          */
-        
+
         for (String key : json.keySet()) {
             String fieldName = key.toUpperCase();
             if (fieldName.startsWith("NETWORK_")) {

+ 118 - 0
com.awspaas.user.apps.donenow_sys/src/com/awspaas/user/apps/donenow_sys/event/GeneralDeactivate.java

@@ -0,0 +1,118 @@
+package com.awspaas.user.apps.donenow_sys.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 GeneralDeactivate 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> Ids = new ArrayList<>();
+
+        if (StringUtils.isNotBlank(boId))
+            Ids.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);
+                String id = jsonObject.getString("_ID");
+                //如果最后两个字符是 _0/_1... 则去掉
+                if (id.substring(id.length() - 2, id.length() - 1).equals("_")) {
+                    id = id.substring(0, id.length() - 2);
+                }
+                Ids.add(id);
+            }
+        }
+
+        if (Ids.size() == 0) {
+            ro.msg("请选择注销记录");
+            return ro.toString();
+        }
+        Connection conn = null;
+        try {
+            conn = DBSql.open();
+            conn.setAutoCommit(false);
+            for (String id : Ids) {
+                BO bo = SDK.getBOAPI().get(boName, id);
+                if (bo == null) {
+                    throw new Exception("数据不存在");
+                }
+                bo.set("CLOSED", 1);
+                Map<String, Object> params = new HashMap<>();
+                params.put("ID", id);
+                params.put("CLOSED", 1);
+                dn.recordFormChanges.record(ctx.getUserContext(), boName, params, "注销", conn);//记录操作日志
+                SDK.getBOAPI().update(boName, bo, conn);
+            }
+            conn.commit();
+        } catch (SQLException e) {
+            e.printStackTrace();
+            try {
+                conn.rollback();
+            } catch (SQLException ex) {
+                r = false;
+            }
+        } catch (Exception e) {
+            ro = ResponseObject.newErrResponse();
+            ro.msg("错误" + e.getMessage());
+            return ro.toString();
+        } 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();
+        }
+    }
+}