瀏覽代碼

河南郸城调度计划 修改方法增加线程锁

1037015548@qq.com 11 月之前
父節點
當前提交
ebf10bd9ca

+ 29 - 0
src/main/java/com/shkpr/service/aimodelpower/bizmgr/WODispatchPlanTmDoBizFun.java

@@ -527,6 +527,35 @@ public class WODispatchPlanTmDoBizFun {
         }
     }
 
+    //TODO 修改计划增加线程锁
+    public static ResponseCode updatePlanClock(JPDispatchPlanInfoUpdate oJsonParam){
+        ResponseCode code = ResponseCode.RESULT_BAD;
+        if (oJsonParam==null)
+            return code;
+
+        CountDownLatchEx latchEx = null;
+        int nRetry = 3;
+        do {
+            try {
+                latchEx = WODispatchPlanLockMgr.tryLatchForPlan(oJsonParam.getPlanId(), 20000);
+            }catch (Exception e){
+                latchEx = null;
+            }
+
+            if (latchEx != null){
+                code = updatePlan(oJsonParam);
+                break;
+            }
+        }while ((--nRetry) > 0);
+
+        if (latchEx != null){
+            latchEx.countDown();
+        }else{
+            code = updatePlan(oJsonParam);
+        }
+        return code;
+    }
+
     //TODO 修改计划
     public static ResponseCode updatePlan(JPDispatchPlanInfoUpdate oJsonParam){
         try {

+ 1 - 1
src/main/java/com/shkpr/service/aimodelpower/controllerapi/woDispatchPlan/WoDispatchPlanInfoController.java

@@ -243,7 +243,7 @@ public class WoDispatchPlanInfoController {
         resResult.setResmsg(MSG_FAILED);
         resResult.setResdata("");
 
-        ResponseCode resCode = WODispatchPlanTmDoBizFun.updatePlan(oJsonParam);
+        ResponseCode resCode = WODispatchPlanTmDoBizFun.updatePlanClock(oJsonParam);
         if (resCode!=null&&resCode==ResponseCode.RESULT_NORMAL){
             resResult.setRescode(ResponseCode.RESULT_NORMAL.toStrCode());
             resResult.setResmsg(MSG_SUCCESS);