ソースを参照

[bug-2418]切换主部门失败

szjbdgzl 1 年間 前
コミット
76f52c5c12

+ 20 - 5
ibps-provider-root/modules/provider-business/src/main/java/com/lc/ibps/sysdata/services/impl/UpdateDataTableImpl.java

@@ -7,6 +7,7 @@ import com.lc.ibps.api.base.constants.StateEnum;
 import com.lc.ibps.base.bo.exception.BoBaseException;
 import com.lc.ibps.base.core.util.AppUtil;
 import com.lc.ibps.base.core.util.BeanUtils;
+import com.lc.ibps.base.core.util.Collections;
 import com.lc.ibps.base.core.util.I18nUtil;
 import com.lc.ibps.base.framework.id.UniqueIdUtil;
 import com.lc.ibps.base.framework.table.ICommonDao;
@@ -149,16 +150,28 @@ public class UpdateDataTableImpl extends GenericProvider implements UpdateDataTa
     //修改方法
     @Override
     public Integer updateDatasContextTable(String tableName, List<Map<String,String>> paramWhere, Map<String, String> paramCond) {
-        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
-        paramCond.put("update_by_", ContextUtil.getCurrentUserId());
-        paramCond.put("update_time_",sdf.format(new Date()));
+        if (getFieldByTableName(tableName)){
+            SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+            paramCond.put("update_by_", ContextUtil.getCurrentUserId());
+            paramCond.put("update_time_",sdf.format(new Date()));
+        }
         return  updateDataTableDao.updateDatasTable(tableName,paramCond,paramWhere);
     }
 
+    private boolean getFieldByTableName(String tableName){
+        String sql = "SELECT *from ibps_bo_column WHERE TABLE_NAME_='%s' and name_ in('update_by_','update_time_')";
+        List list = commonDao.query(String.format(sql,tableName));
+        if(!Collections.isEmpty(list) && list.size()==2){
+            return true;
+        }
+        return false;
+    }
+
     @Override
     @Transactional(rollbackFor = Exception.class)
     public Integer updateBatchContextTable(String tableName, List<Map<String, String>> list) {
        Integer integer = 1;
+       boolean flag = getFieldByTableName(tableName);
             if (list!=null&&list.size()>0){
                 SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
                 for (int i = 0; i < list.size(); i++) {
@@ -167,8 +180,10 @@ public class UpdateDataTableImpl extends GenericProvider implements UpdateDataTa
                     JSONObject whereObj = JSONObject.parseObject(String.valueOf(list.get(i).get("where")));
 
                     if (setObj != null && whereObj != null){
-                        setObj.put("update_by_", ContextUtil.getCurrentUserId());
-                        setObj.put("update_time_",sdf.format(new Date()));
+                        if(flag){
+                            setObj.put("update_by_", ContextUtil.getCurrentUserId());
+                            setObj.put("update_time_",sdf.format(new Date()));
+                        }
                         StringBuilder wsf = new StringBuilder(" ");
                         StringBuilder psf = new StringBuilder(" ");
                         // set  sql 拼接