zhangyao пре 2 месеци
родитељ
комит
52f37202d7

+ 23 - 39
com.awspaas.user.apps.donenow_crm/src/com/awspaas/user/apps/donenow_crm/controller/accountController.java

@@ -36,15 +36,13 @@ public class accountController extends BaseController {
      */
     @Mapping(value = "com.awspaas.user.apps.donenow_DelAccount")
     public ResponseObject delAccount(UserContext uc, String ids) throws SQLException {
-        if (StringUtils.isBlank(ids))
-            return ResponseObject.newErrResponse("请选择要删除的数据");
+        if (StringUtils.isBlank(ids)) return ResponseObject.newErrResponse("请选择要删除的数据");
 
         String tableName = "BO_EU_DNCRM_ACCOUNT";
 
         //引用校验
         String result = verifyDel(tableName, ids);
-        if (result != null)
-            return ResponseObject.newErrResponse(result);
+        if (result != null) return ResponseObject.newErrResponse(result);
 
         Connection conn = null;
         try {
@@ -68,8 +66,7 @@ public class accountController extends BaseController {
 
                     //删除 组织中对应的用户
                     String userId = DBSql.getString(conn, "SELECT USERID FROM orguser WHERE ext5=? AND CLOSED=0 ", new Object[]{contact.getId()});
-                    if (StringUtils.isNotBlank(userId))
-                        SDK.getORGAPI().disabledUser(userId);//禁用组织中用户
+                    if (StringUtils.isNotBlank(userId)) SDK.getORGAPI().disabledUser(userId);//禁用组织中用户
                 }
 
                 List<BO> installedProducts = SDK.getBOAPI().query("BO_EU_DNCRM_INSTALLED_PRODUCT").addQuery("ACCOUNT_ID=", id).addQuery("CLOSED=", 0).list();
@@ -94,8 +91,7 @@ public class accountController extends BaseController {
         } catch (Exception e) {
             return ResponseObject.newErrResponse(e.getMessage());
         } finally {
-            if (conn != null)
-                DBSql.close(conn);
+            if (conn != null) DBSql.close(conn);
         }
         return ResponseObject.newOkResponse();
     }
@@ -119,15 +115,13 @@ public class accountController extends BaseController {
      */
     @Mapping(value = "com.awspaas.user.apps.donenow_DelContact")
     public ResponseObject delContact(UserContext uc, String ids) throws SQLException {
-        if (StringUtils.isBlank(ids))
-            return ResponseObject.newErrResponse("请选择要删除的数据");
+        if (StringUtils.isBlank(ids)) return ResponseObject.newErrResponse("请选择要删除的数据");
 
         String tableName = "BO_EU_DNCRM_CONTACT";
 
         //引用校验
         String result = verifyDel(tableName, ids);
-        if (result != null)
-            return ResponseObject.newErrResponse(result);
+        if (result != null) return ResponseObject.newErrResponse(result);
 
         Connection conn = null;
         try {
@@ -146,7 +140,7 @@ public class accountController extends BaseController {
                     throw new Exception("该联系人有关联的工单或任务");
                 }
 
-                if (DBSql.getInt(conn, "SELECT COUNT(*) from BO_EU_DNCOM_ACTIVITY where CREATEUSER=(SELECT USERID FROM orguser WHERE ext5=? AND CLOSED=0 ) and closed=0", new Object[]{id}) > 0) {
+                if (DBSql.getInt(conn, "SELECT COUNT(*) from BO_EU_DNCOM_ACTIVITY where CREATEUSER=(SELECT USERID FROM orguser WHERE ext5=? ) ", new Object[]{id}) > 0) {
                     throw new Exception("该联系人在自助服务台创建过工单备注");
                 }
 /*
@@ -172,8 +166,7 @@ public class accountController extends BaseController {
 
                 //删除 组织中对应的用户
                 String userId = DBSql.getString(conn, "SELECT USERID FROM orguser WHERE ext5=? AND CLOSED=0 ", new Object[]{contact.getId()});
-                if (StringUtils.isNotBlank(userId))
-                    SDK.getORGAPI().disabledUser(userId);//禁用组织中用户
+                if (StringUtils.isNotBlank(userId)) SDK.getORGAPI().disabledUser(userId);//禁用组织中用户
 
                 //配置项逻辑删除
                 List<BO> installedProducts = SDK.getBOAPI().query("BO_EU_DNCRM_INSTALLED_PRODUCT").addQuery("CONTACT_ID=", id).addQuery("CLOSED=", 0).list();
@@ -192,8 +185,7 @@ public class accountController extends BaseController {
         } catch (Exception e) {
             return ResponseObject.newErrResponse(e.getMessage());
         } finally {
-            if (conn != null)
-                DBSql.close(conn);
+            if (conn != null) DBSql.close(conn);
         }
         return ResponseObject.newOkResponse();
 
@@ -209,15 +201,13 @@ public class accountController extends BaseController {
     @Mapping(value = "com.awspaas.user.apps.donenow_DelInstallProd")
     public ResponseObject delInstallProd(UserContext uc, String ids) throws SQLException {
 
-        if (StringUtils.isBlank(ids))
-            return ResponseObject.newErrResponse("请选择要删除的数据");
+        if (StringUtils.isBlank(ids)) return ResponseObject.newErrResponse("请选择要删除的数据");
 
         String tableName = "BO_EU_DNCRM_INSTALLED_PRODUCT";
 
         //引用校验
         String result = verifyDel(tableName, ids);
-        if (result != null)
-            return ResponseObject.newErrResponse(result);
+        if (result != null) return ResponseObject.newErrResponse(result);
 
         Connection conn = null;
         try {
@@ -250,8 +240,7 @@ public class accountController extends BaseController {
         } catch (Exception e) {
             return ResponseObject.newErrResponse(e.getMessage());
         } finally {
-            if (conn != null)
-                DBSql.close(conn);
+            if (conn != null) DBSql.close(conn);
         }
 
         return ResponseObject.newOkResponse();
@@ -268,15 +257,13 @@ public class accountController extends BaseController {
     @Mapping(value = "com.awspaas.user.apps.donenow_delLocation")
     public ResponseObject delLocation(UserContext uc, String ids) throws SQLException {
 
-        if (StringUtils.isBlank(ids))
-            return ResponseObject.newErrResponse("请选择要删除的数据");
+        if (StringUtils.isBlank(ids)) return ResponseObject.newErrResponse("请选择要删除的数据");
 
         String tableName = "BO_EU_DNCRM_LOCATION";
 
         //引用校验
         String result = verifyDel(tableName, ids);
-        if (result != null)
-            return ResponseObject.newErrResponse(result);
+        if (result != null) return ResponseObject.newErrResponse(result);
 
         Connection conn = null;
         try {
@@ -300,8 +287,7 @@ public class accountController extends BaseController {
         } catch (Exception e) {
             return ResponseObject.newErrResponse(e.getMessage());
         } finally {
-            if (conn != null)
-                DBSql.close(conn);
+            if (conn != null) DBSql.close(conn);
         }
 
         return ResponseObject.newOkResponse();
@@ -315,20 +301,19 @@ public class accountController extends BaseController {
             sql = verify.getString("SEL_SQL");
             for (String id : ids.split(",")) {
                 id = DBSql.getString("select ID from " + tableName + " where ID=?", new Object[]{id});
-                if (StringUtils.isBlank(id) || id.length() < 2)
-                    continue;
-                String sqlById = sql.replace("**id**", "'" + id + "'");
+                if (StringUtils.isBlank(id) || id.length() < 2) continue;
+
+                //String sqlById = sql.replace("**id**", "'" + id + "'");
+                String sqlById = sql.replaceAll("\\*\\*id\\*\\*", "'" + id + "'");
 
                 logger.info("BO_EU_DNSYS_DELETE_VERIFY----" + sqlById);
 
                 List<RowMap> list = DBSql.getMaps(sqlById);
                 if (!list.isEmpty()) {
-                    String errMsg = null;
+                    String errMsg = StringUtils.EMPTY;
                     for (RowMap rowMap : list) {
-                        if (rowMap.containsKey("name"))
-                            rowMap.put("NAME", rowMap.get("name"));
-                        if (rowMap.containsKey("num"))
-                            rowMap.put("NUM", rowMap.get("num"));
+                        if (rowMap.containsKey("name")) rowMap.put("NAME", rowMap.get("name"));
+                        if (rowMap.containsKey("num")) rowMap.put("NUM", rowMap.get("num"));
 
                         errMsg += rowMap.getString("NAME") + rowMap.getString("NUM") + "\r\n";
                     }
@@ -431,8 +416,7 @@ public class accountController extends BaseController {
         List<String> values = new ArrayList<>();
         for (String key : json.keySet()) {
             String value = json.getString(key);
-            if (StringUtils.isBlank(value))
-                value = "";
+            if (StringUtils.isBlank(value)) value = "";
             if (value.contains("[") && value.length() > 4) {
                 value = value.substring(2, 3);
             }