Browse Source

日志填报异字段超长后提示问题

liuyc 1 year ago
parent
commit
8de0c426f1

+ 25 - 7
blade-service/blade-manager/src/main/java/org/springblade/manager/service/impl/ExcelTabServiceImpl.java

@@ -490,7 +490,7 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
             //为空,默认今天
             recordTime = DateUtil.format(new Date(), "yyyy-MM-dd");
         }
-        // 为数据集
+        //对应实体表的数据id = businessIds
         String businessIds = tableInfoList.stream().map(TableInfo::getBusinessId).filter(ObjectUtils::isNotEmpty).collect(Collectors.joining(","));
         String ids = "";
         if (StringUtils.isEmpty(businessIds)) {
@@ -544,14 +544,32 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
             try {
                 this.jdbcTemplate.execute(sql.toString());
             } catch (Exception e) {
-                throw new ServiceException("当前字段值太长,请减少输入的字符数量或联系管理员");
+                String errorKeyName = null;
+                String errorMessage = e.getMessage();
+                if (StringUtils.isNotEmpty(errorMessage)) {
+                    String errorKey = null;
+                    if (errorMessage.contains("long for column ") && errorMessage.contains(" at ")) {
+                        errorKey = errorMessage.split("long for column ")[1].split(" at ")[0];
+                    }
+                    if (StringUtils.isNotEmpty(errorKey)) {
+                        //获取公有原始节点实体表id = init_table_id
+                        WbsTree wbsTree = jdbcTemplate.queryForObject("select init_table_id from m_wbs_tree where id = " + tableNode.getId(), new BeanPropertyRowMapper<>(WbsTree.class));
+                        if (wbsTree != null) {
+                            //获取字段名
+                            WbsFormElement tabElement = jdbcTemplate.queryForObject("select e_name from m_wbs_form_element where f_id = " + wbsTree.getInitTableId() + " and e_key = " + errorKey, new BeanPropertyRowMapper<>(WbsFormElement.class));
+                            if (tabElement != null) {
+                                errorKeyName = tabElement.getEName();
+                            }
+                        }
+                    }
+                }
+                e.printStackTrace();
+                if (StringUtils.isNotEmpty(errorKeyName)) {
+                    throw new ServiceException("【" + errorKeyName + "】字段值太长,请减少输入的字符数量或联系管理员");
+                }
             }
 
             List<Object> linkTabIds = tableInfo.getLinkTabIds();
-            /*if (linkTabIds == null || linkTabIds.size() <= 0) {
-                //这一步主要为了兼容同工序时只想在第一张勾选的情况
-                linkTabIds = tableInfoList.get(0).getLinkTabIds();
-            }*/
             List<JSONObject> logWbsList = new ArrayList<>();
             if (linkTabIds != null && linkTabIds.size() > 0) {
                 //处理每个表格的关联情况
@@ -1728,7 +1746,7 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
                 } else {
                     R bussPdfInfo = this.getBussPdfInfo(wbsInfo.getPKeyId());
                     if (bussPdfInfo.getCode() == 200) {
-                        if (StringUtils.isNotBlank(bussPdfInfo.getData()+"")) {
+                        if (StringUtils.isNotBlank(bussPdfInfo.getData() + "")) {
                             data.add(bussPdfInfo.getData() + "");
                         }
                     }