|
@@ -1,7 +1,9 @@
|
|
package com.management.platform.service.impl;
|
|
package com.management.platform.service.impl;
|
|
|
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
@@ -342,42 +344,52 @@ public class CusTableColumnServiceImpl extends ServiceImpl<CusTableColumnMapper,
|
|
msg.setError("主业务表无法识别,请联系管理员");
|
|
msg.setError("主业务表无法识别,请联系管理员");
|
|
return msg;
|
|
return msg;
|
|
}
|
|
}
|
|
-// WxCorpInfo wxCorpInfo = wxCorpInfoMapper.selectOne(new QueryWrapper<WxCorpInfo>().eq("company_id", user.getCompanyId()));
|
|
|
|
|
|
+ WxCorpInfo wxCorpInfo = wxCorpInfoMapper.selectOne(new QueryWrapper<WxCorpInfo>().eq("company_id", user.getCompanyId()));
|
|
if(StringUtils.isNotBlank(tableAlias) && StringUtils.isNotBlank(tableName)){
|
|
if(StringUtils.isNotBlank(tableAlias) && StringUtils.isNotBlank(tableName)){
|
|
String s = cusReportForm.getExecuteSql()+" and "+tableAlias+".company_id="+user.getCompanyId()+" ";
|
|
String s = cusReportForm.getExecuteSql()+" and "+tableAlias+".company_id="+user.getCompanyId()+" ";
|
|
-
|
|
|
|
-// List<FormTransCondition> formTransConditions = JSONObject.parseArray(cusReportForm.getFormTransConditionJson(), FormTransCondition.class);
|
|
|
|
-// for (FormTransCondition formTransCondition : formTransConditions) {
|
|
|
|
-// String str = formTransCondition.getTblAlias()+"."+formTransCondition.getColName();
|
|
|
|
-// String replaceObj = str+" like concat('%','"+formTransCondition.getUseVal()+"','%')";
|
|
|
|
-// if(1 == formTransCondition.getTransType()){
|
|
|
|
-// HashMap<String, List> result = null;
|
|
|
|
-// try {
|
|
|
|
-// result = wxCorpInfoService.getOpenId(wxCorpInfo.getCorpid(), formTransCondition.getUseVal(), null,1,200);
|
|
|
|
-// } catch (Exception e) {
|
|
|
|
-// e.printStackTrace();
|
|
|
|
-// msg.setError("企微转义有误,请联系管理员");
|
|
|
|
-// return msg;
|
|
|
|
-// }
|
|
|
|
-// List users = result.get("user");
|
|
|
|
-// List<User> realUser = userMapper.getUserByDepartment(null, user.getCompanyId(), null,null, null, null, null, users);
|
|
|
|
-// String replaceStr = str+" in(";
|
|
|
|
-// int count = 0;
|
|
|
|
-// for (User tmpUser : realUser) {
|
|
|
|
-// replaceStr += "'"+tmpUser.getName()+"'";
|
|
|
|
-// count++;
|
|
|
|
-// if(count<realUser.size()){
|
|
|
|
-// replaceStr += ", ";
|
|
|
|
-// }
|
|
|
|
-// }
|
|
|
|
-// replaceStr +=") ";
|
|
|
|
-//
|
|
|
|
-// s.replace(replaceObj,replaceStr);
|
|
|
|
-//
|
|
|
|
-// } else if (2 == formTransCondition.getTransType()) {
|
|
|
|
-//
|
|
|
|
-// }
|
|
|
|
-// }
|
|
|
|
|
|
+ if(1 == wxCorpInfo.getSaasSyncContact()){
|
|
|
|
+ List<FormTransCondition> formTransConditions = JSONObject.parseArray(cusReportForm.getFormTransConditionJson(), FormTransCondition.class);
|
|
|
|
+ for (FormTransCondition formTransCondition : formTransConditions) {
|
|
|
|
+ String str = formTransCondition.getTblAlias()+"."+formTransCondition.getColName();
|
|
|
|
+ String replaceObj = str+" like concat('%','"+formTransCondition.getUseVal()+"','%')";
|
|
|
|
+ if(1 == formTransCondition.getTransType()){
|
|
|
|
+ HashMap<String, List> result = null;
|
|
|
|
+ try {
|
|
|
|
+ result = wxCorpInfoService.getOpenId(wxCorpInfo.getCorpid(), formTransCondition.getUseVal(), null,1,200);
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ e.printStackTrace();
|
|
|
|
+ msg.setError("企微转义有误,请联系管理员");
|
|
|
|
+ return msg;
|
|
|
|
+ }
|
|
|
|
+ List users = result.get("user");
|
|
|
|
+ List<User> realUser = userMapper.getUserByDepartment(null, user.getCompanyId(), null,null, null, null, null, users);
|
|
|
|
+ String replaceStr = str+" in(";
|
|
|
|
+ int count = 0;
|
|
|
|
+ for (User tmpUser : realUser) {
|
|
|
|
+ replaceStr += "'"+tmpUser.getName()+"'";
|
|
|
|
+ count++;
|
|
|
|
+ if(count<realUser.size()){
|
|
|
|
+ replaceStr += ", ";
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ replaceStr +=") ";
|
|
|
|
+ s.replace(replaceObj,replaceStr);
|
|
|
|
+ } else if (2 == formTransCondition.getTransType()) {
|
|
|
|
+ Integer deptWxId = null;
|
|
|
|
+ try {
|
|
|
|
+ deptWxId = wxCorpInfoService.searchCorpWxDeptId(wxCorpInfo.getCorpid(), formTransCondition.getUseVal());
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ e.printStackTrace();
|
|
|
|
+ msg.setError("企微转义有误,请联系管理员");
|
|
|
|
+ return msg;
|
|
|
|
+ }
|
|
|
|
+ if(null != deptWxId){
|
|
|
|
+ String replaceStr = str+" ="+deptWxId+" ";
|
|
|
|
+ s.replace(replaceObj,replaceStr);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
|
|
cusReportForm.setExecuteSql(s);
|
|
cusReportForm.setExecuteSql(s);
|
|
|
|
|
|
@@ -676,6 +688,8 @@ public class CusTableColumnServiceImpl extends ServiceImpl<CusTableColumnMapper,
|
|
public HttpRespMsg getFormResByFormId(Integer formId, HttpServletRequest request) {
|
|
public HttpRespMsg getFormResByFormId(Integer formId, HttpServletRequest request) {
|
|
HttpRespMsg msg = new HttpRespMsg();
|
|
HttpRespMsg msg = new HttpRespMsg();
|
|
List<Map<String,Object>> columnList = new ArrayList<>();
|
|
List<Map<String,Object>> columnList = new ArrayList<>();
|
|
|
|
+ List<Map<String,Object>> resColumnList = new ArrayList<>();
|
|
|
|
+ User user = userMapper.selectById(request.getHeader("token"));
|
|
CusReportForm cusReportForm = cusReportFormMapper.selectById(formId);
|
|
CusReportForm cusReportForm = cusReportFormMapper.selectById(formId);
|
|
if(null == cusReportForm){
|
|
if(null == cusReportForm){
|
|
msg.setError("未找到该报表,请联系管理员");
|
|
msg.setError("未找到该报表,请联系管理员");
|
|
@@ -691,7 +705,143 @@ public class CusTableColumnServiceImpl extends ServiceImpl<CusTableColumnMapper,
|
|
msg.setError("SQL语句有误,请联系管理员");
|
|
msg.setError("SQL语句有误,请联系管理员");
|
|
return msg;
|
|
return msg;
|
|
}
|
|
}
|
|
- msg.setData(columnList);
|
|
|
|
|
|
+
|
|
|
|
+ //转换固定值
|
|
|
|
+ List<FormFieldHead> formFieldHeads = JSONArray.parseArray(cusReportForm.getFormFieldHead(), FormFieldHead.class);
|
|
|
|
+ List<ColumnFixTrans> columnFixTrans = columnFixTransMapper.selectList(null);
|
|
|
|
+ Map<String, List<ColumnFixTrans>> tableColumnFixTransMap = columnFixTrans.stream()
|
|
|
|
+ .collect(Collectors.groupingBy(ColumnFixTrans::getTblName));// key tblName
|
|
|
|
+
|
|
|
|
+ //根据表头获取 'xxx' --> 别名.字段名 --> 表名.字段名
|
|
|
|
+ Map<String, FormFieldHead> columnAliasMap = new HashMap<>();
|
|
|
|
+ for (FormFieldHead formFieldHead : formFieldHeads) {
|
|
|
|
+ columnAliasMap.put(formFieldHead.getColumnVal(),formFieldHead);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if(CollectionUtils.isNotEmpty(columnList)){
|
|
|
|
+
|
|
|
|
+ List<FormTransColumn> checkColumns = formTransColumnMapper.selectList(new LambdaQueryWrapper<FormTransColumn>());
|
|
|
|
+ Map<String, List<FormTransColumn>> tblColumnMap = new HashMap<>();
|
|
|
|
+ if(CollectionUtils.isNotEmpty(checkColumns)){
|
|
|
|
+ tblColumnMap = checkColumns.stream()
|
|
|
|
+ .collect(Collectors.groupingBy(FormTransColumn::getTblName));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ Map<String,List<String>> indexMap = new HashMap<>(2);
|
|
|
|
+ indexMap.put("userName",new ArrayList<>());
|
|
|
|
+ indexMap.put("deptName",new ArrayList<>());
|
|
|
|
+ Map<String,String> tableNameAliasMap = new HashMap<>();
|
|
|
|
+ Matcher mainMatcher = MAIN_TABLE_PATTERN.matcher(tableColumnSql);
|
|
|
|
+ if (mainMatcher.find()) {
|
|
|
|
+ tableNameAliasMap.put(mainMatcher.group(1),mainMatcher.group(2));
|
|
|
|
+ } else {
|
|
|
|
+ msg.setError("主业务表无法识别,请联系管理员");
|
|
|
|
+ return msg;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ Matcher joinMatcher = JOIN_TABLE_PATTERN.matcher(tableColumnSql);
|
|
|
|
+ while (joinMatcher.find()){
|
|
|
|
+ tableNameAliasMap.put(joinMatcher.group(1),joinMatcher.group(2));
|
|
|
|
+ }
|
|
|
|
+ for (String tableName : tableNameAliasMap.keySet()) {
|
|
|
|
+ List<FormTransColumn> tmpColList = tblColumnMap.get(tableName);
|
|
|
|
+ String tableAlias = tableNameAliasMap.get(tableName);
|
|
|
|
+ if(CollectionUtils.isNotEmpty(tmpColList)){
|
|
|
|
+ for (FormTransColumn formTransColumn : tmpColList) {
|
|
|
|
+ String col = tableAlias+"."+formTransColumn.getColName();
|
|
|
|
+ if(tableColumnSql.contains(col)){
|
|
|
|
+ if(1 == formTransColumn.getTransType()){
|
|
|
|
+ //当前位置的是人名,需要转义
|
|
|
|
+ for (int i = 0; i < formFieldHeads.size(); i++) {
|
|
|
|
+ if(formFieldHeads.get(i).getTableName().equals(tableName)
|
|
|
|
+ &&formFieldHeads.get(i).getColumnName().equals(formTransColumn.getColName())
|
|
|
|
+ ){
|
|
|
|
+ List<String> tmpList = indexMap.get("userName");
|
|
|
|
+ tmpList.add(formFieldHeads.get(i).getColumnVal());
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ else if (2 == formTransColumn.getTransType()) {
|
|
|
|
+ //当前位置是部门,需要转义
|
|
|
|
+ for (int i = 0; i < formFieldHeads.size(); i++) {
|
|
|
|
+ if(formFieldHeads.get(i).getTableName().equals(tableName)
|
|
|
|
+ &&formFieldHeads.get(i).getColumnName().equals(formTransColumn.getColName())
|
|
|
|
+ ){
|
|
|
|
+ List<String> tmpList = indexMap.get("deptName");
|
|
|
|
+ tmpList.add(formFieldHeads.get(i).getColumnVal());
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ List<User> userList = userMapper.selectList(new LambdaQueryWrapper<User>().eq(User::getCompanyId, user.getCompanyId()));
|
|
|
|
+ WxCorpInfo wxCorpInfo = wxCorpInfoMapper.selectOne(new LambdaQueryWrapper<WxCorpInfo>().eq(WxCorpInfo::getCompanyId, user.getCompanyId()));
|
|
|
|
+ for (Map<String, Object> data : columnList) {
|
|
|
|
+ String valRes = "";
|
|
|
|
+ Map<String,Object> map = new HashMap<>();
|
|
|
|
+ for (String key : columnList.get(0).keySet()) {
|
|
|
|
+ //固定值转换
|
|
|
|
+ FormFieldHead formFieldHead = columnAliasMap.get(key);//字段对应别名和表
|
|
|
|
+ List<ColumnFixTrans> transColList = tableColumnFixTransMap.get(formFieldHead.getTableName());//固定值字段集合
|
|
|
|
+ List<ColumnFixTrans> currentFixValList = transColList.stream()
|
|
|
|
+ .filter(t -> t.getColName().equals(formFieldHead.getColumnName()))
|
|
|
|
+ .collect(Collectors.toList());//当前字段固定值对照值
|
|
|
|
+ if(CollectionUtils.isNotEmpty(currentFixValList)){
|
|
|
|
+ Map<String, String> valMeanMap = currentFixValList.stream()
|
|
|
|
+ .collect(Collectors.toMap(ColumnFixTrans::getColVal, ColumnFixTrans::getValMean));
|
|
|
|
+ Object value = data.get(key);
|
|
|
|
+ String mean = valMeanMap.get(value.toString());
|
|
|
|
+ valRes = mean;
|
|
|
|
+ }else{
|
|
|
|
+ //转义
|
|
|
|
+ List<String> userNameIndexes = indexMap.get("userName");
|
|
|
|
+ List<String> deptNameIndexes = indexMap.get("deptName");
|
|
|
|
+ if(1 == user.getUserNameNeedTranslate()){
|
|
|
|
+ Object value = data.get(key);
|
|
|
|
+ if (value == null) {
|
|
|
|
+ } else {
|
|
|
|
+ String val = value.toString();
|
|
|
|
+ if(wxCorpInfo!=null&&wxCorpInfo.getSaasSyncContact()==1){
|
|
|
|
+ if(CollectionUtils.isNotEmpty(userNameIndexes) && userNameIndexes.contains(key)){
|
|
|
|
+ String name = val;
|
|
|
|
+ Optional<User> first = userList.stream().filter(u -> u.getName().equals(name)).findFirst();
|
|
|
|
+ if(first.isPresent()){
|
|
|
|
+ val = "$userName="+first.get().getCorpwxUserid()+"$";
|
|
|
|
+ }else {
|
|
|
|
+ val = "";
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ if(CollectionUtils.isNotEmpty(deptNameIndexes) && deptNameIndexes.contains(key)){
|
|
|
|
+ String name = val;
|
|
|
|
+ Optional<User> first = userList.stream().filter(u -> u.getName().equals(name)).findFirst();
|
|
|
|
+ if(first.isPresent()){
|
|
|
|
+ val = "$departmentName="+first.get().getCorpwxDeptid()+"$";
|
|
|
|
+ }else {
|
|
|
|
+ val = "";
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ valRes = val;
|
|
|
|
+ }
|
|
|
|
+ }else{
|
|
|
|
+ Object value = data.get(key);
|
|
|
|
+ if (value == null) {
|
|
|
|
+ valRes = "";
|
|
|
|
+ } else {
|
|
|
|
+ valRes = value.toString();
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ map.put(key,valRes);
|
|
|
|
+ }
|
|
|
|
+ resColumnList.add(map);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ msg.setData(resColumnList);
|
|
return msg;
|
|
return msg;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -742,7 +892,7 @@ public class CusTableColumnServiceImpl extends ServiceImpl<CusTableColumnMapper,
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
- public HttpRespMsg getResByFormJson(String formJson, HttpServletRequest request) {
|
|
|
|
|
|
+ public HttpRespMsg getResByFormJson(String formJson,String formTransConditionJson, HttpServletRequest request) {
|
|
HttpRespMsg msg = new HttpRespMsg();
|
|
HttpRespMsg msg = new HttpRespMsg();
|
|
List<Map<String,Object>> columnList = new ArrayList<>();
|
|
List<Map<String,Object>> columnList = new ArrayList<>();
|
|
Matcher deleteMatcher = DELETE_SGIN_PATTERN.matcher(formJson);
|
|
Matcher deleteMatcher = DELETE_SGIN_PATTERN.matcher(formJson);
|
|
@@ -752,6 +902,52 @@ public class CusTableColumnServiceImpl extends ServiceImpl<CusTableColumnMapper,
|
|
msg.setError("包含非法字符,无法执行");
|
|
msg.setError("包含非法字符,无法执行");
|
|
return msg;
|
|
return msg;
|
|
}
|
|
}
|
|
|
|
+ User user = userMapper.selectById(request.getHeader("token"));
|
|
|
|
+ WxCorpInfo wxCorpInfo = wxCorpInfoMapper.selectOne(new QueryWrapper<WxCorpInfo>().eq("company_id", user.getCompanyId()));
|
|
|
|
+ if(1 == wxCorpInfo.getSaasSyncContact()){
|
|
|
|
+ List<FormTransCondition> formTransConditions = JSONObject.parseArray(formTransConditionJson, FormTransCondition.class);
|
|
|
|
+ for (FormTransCondition formTransCondition : formTransConditions) {
|
|
|
|
+ String str = formTransCondition.getTblAlias()+"."+formTransCondition.getColName();
|
|
|
|
+ String replaceObj = str+" like concat('%','"+formTransCondition.getUseVal()+"','%')";
|
|
|
|
+ if(1 == formTransCondition.getTransType()){
|
|
|
|
+ HashMap<String, List> result = null;
|
|
|
|
+ try {
|
|
|
|
+ result = wxCorpInfoService.getOpenId(wxCorpInfo.getCorpid(), formTransCondition.getUseVal(), null,1,200);
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ e.printStackTrace();
|
|
|
|
+ msg.setError("企微转义有误,请联系管理员");
|
|
|
|
+ return msg;
|
|
|
|
+ }
|
|
|
|
+ List users = result.get("user");
|
|
|
|
+ List<User> realUser = userMapper.getUserByDepartment(null, user.getCompanyId(), null,null, null, null, null, users);
|
|
|
|
+ String replaceStr = str+" in(";
|
|
|
|
+ int count = 0;
|
|
|
|
+ for (User tmpUser : realUser) {
|
|
|
|
+ replaceStr += "'"+tmpUser.getName()+"'";
|
|
|
|
+ count++;
|
|
|
|
+ if(count<realUser.size()){
|
|
|
|
+ replaceStr += ", ";
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ replaceStr +=") ";
|
|
|
|
+ formJson.replace(replaceObj,replaceStr);
|
|
|
|
+ } else if (2 == formTransCondition.getTransType()) {
|
|
|
|
+ Integer deptWxId = null;
|
|
|
|
+ try {
|
|
|
|
+ deptWxId = wxCorpInfoService.searchCorpWxDeptId(wxCorpInfo.getCorpid(), formTransCondition.getUseVal());
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ e.printStackTrace();
|
|
|
|
+ msg.setError("企微转义有误,请联系管理员");
|
|
|
|
+ return msg;
|
|
|
|
+ }
|
|
|
|
+ if(null != deptWxId){
|
|
|
|
+ String replaceStr = str+" ="+deptWxId+" ";
|
|
|
|
+ formJson.replace(replaceObj,replaceStr);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ List<Map<String,Object>> resColumnList = new ArrayList<>();
|
|
try (Connection connection = dataSource.getConnection()) {
|
|
try (Connection connection = dataSource.getConnection()) {
|
|
PreparedStatement preparedStatement = connection.prepareStatement(formJson);
|
|
PreparedStatement preparedStatement = connection.prepareStatement(formJson);
|
|
ResultSet resultSet = preparedStatement.executeQuery();
|
|
ResultSet resultSet = preparedStatement.executeQuery();
|
|
@@ -761,6 +957,139 @@ public class CusTableColumnServiceImpl extends ServiceImpl<CusTableColumnMapper,
|
|
msg.setError("SQL语句有误,请联系管理员");
|
|
msg.setError("SQL语句有误,请联系管理员");
|
|
return msg;
|
|
return msg;
|
|
}
|
|
}
|
|
|
|
+// if(CollectionUtils.isNotEmpty(columnList)){
|
|
|
|
+// //转换固定值
|
|
|
|
+// List<FormFieldHead> formFieldHeads = JSONArray.parseArray(cusReportForm.getFormFieldHead(), FormFieldHead.class);
|
|
|
|
+// List<ColumnFixTrans> columnFixTrans = columnFixTransMapper.selectList(null);
|
|
|
|
+// Map<String, List<ColumnFixTrans>> tableColumnFixTransMap = columnFixTrans.stream()
|
|
|
|
+// .collect(Collectors.groupingBy(ColumnFixTrans::getTblName));// key tblName
|
|
|
|
+//
|
|
|
|
+// //根据表头获取 'xxx' --> 别名.字段名 --> 表名.字段名
|
|
|
|
+// Map<String, FormFieldHead> columnAliasMap = new HashMap<>();
|
|
|
|
+// for (FormFieldHead formFieldHead : formFieldHeads) {
|
|
|
|
+// columnAliasMap.put(formFieldHead.getColumnVal(),formFieldHead);
|
|
|
|
+// }
|
|
|
|
+//
|
|
|
|
+// List<FormTransColumn> checkColumns = formTransColumnMapper.selectList(new LambdaQueryWrapper<FormTransColumn>());
|
|
|
|
+// Map<String, List<FormTransColumn>> tblColumnMap = new HashMap<>();
|
|
|
|
+// if(CollectionUtils.isNotEmpty(checkColumns)){
|
|
|
|
+// tblColumnMap = checkColumns.stream()
|
|
|
|
+// .collect(Collectors.groupingBy(FormTransColumn::getTblName));
|
|
|
|
+// }
|
|
|
|
+//
|
|
|
|
+// Map<String,List<String>> indexMap = new HashMap<>(2);
|
|
|
|
+// indexMap.put("userName",new ArrayList<>());
|
|
|
|
+// indexMap.put("deptName",new ArrayList<>());
|
|
|
|
+// Map<String,String> tableNameAliasMap = new HashMap<>();
|
|
|
|
+// Matcher mainMatcher = MAIN_TABLE_PATTERN.matcher(formJson);
|
|
|
|
+// if (mainMatcher.find()) {
|
|
|
|
+// tableNameAliasMap.put(mainMatcher.group(1),mainMatcher.group(2));
|
|
|
|
+// } else {
|
|
|
|
+// msg.setError("主业务表无法识别,请联系管理员");
|
|
|
|
+// return msg;
|
|
|
|
+// }
|
|
|
|
+//
|
|
|
|
+// Matcher joinMatcher = JOIN_TABLE_PATTERN.matcher(formJson);
|
|
|
|
+// while (joinMatcher.find()){
|
|
|
|
+// tableNameAliasMap.put(joinMatcher.group(1),joinMatcher.group(2));
|
|
|
|
+// }
|
|
|
|
+// for (String tableName : tableNameAliasMap.keySet()) {
|
|
|
|
+// List<FormTransColumn> tmpColList = tblColumnMap.get(tableName);
|
|
|
|
+// String tableAlias = tableNameAliasMap.get(tableName);
|
|
|
|
+// if(CollectionUtils.isNotEmpty(tmpColList)){
|
|
|
|
+// for (FormTransColumn formTransColumn : tmpColList) {
|
|
|
|
+// String col = tableAlias+"."+formTransColumn.getColName();
|
|
|
|
+// if(formJson.contains(col)){
|
|
|
|
+// if(1 == formTransColumn.getTransType()){
|
|
|
|
+// //当前位置的是人名,需要转义
|
|
|
|
+// for (int i = 0; i < formFieldHeads.size(); i++) {
|
|
|
|
+// if(formFieldHeads.get(i).getTableName().equals(tableName)
|
|
|
|
+// &&formFieldHeads.get(i).getColumnName().equals(formTransColumn.getColName())
|
|
|
|
+// ){
|
|
|
|
+// List<String> tmpList = indexMap.get("userName");
|
|
|
|
+// tmpList.add(formFieldHeads.get(i).getColumnVal());
|
|
|
|
+// }
|
|
|
|
+// }
|
|
|
|
+// }
|
|
|
|
+// else if (2 == formTransColumn.getTransType()) {
|
|
|
|
+// //当前位置是部门,需要转义
|
|
|
|
+// for (int i = 0; i < formFieldHeads.size(); i++) {
|
|
|
|
+// if(formFieldHeads.get(i).getTableName().equals(tableName)
|
|
|
|
+// &&formFieldHeads.get(i).getColumnName().equals(formTransColumn.getColName())
|
|
|
|
+// ){
|
|
|
|
+// List<String> tmpList = indexMap.get("deptName");
|
|
|
|
+// tmpList.add(formFieldHeads.get(i).getColumnVal());
|
|
|
|
+// }
|
|
|
|
+// }
|
|
|
|
+// }
|
|
|
|
+// }
|
|
|
|
+// }
|
|
|
|
+// }
|
|
|
|
+// }
|
|
|
|
+// List<User> userList = userMapper.selectList(new LambdaQueryWrapper<User>().eq(User::getCompanyId, user.getCompanyId()));
|
|
|
|
+//
|
|
|
|
+// for (Map<String, Object> data : columnList) {
|
|
|
|
+// String valRes = "";
|
|
|
|
+// Map<String,Object> map = new HashMap<>();
|
|
|
|
+// for (String key : columnList.get(0).keySet()) {
|
|
|
|
+// //固定值转换
|
|
|
|
+// FormFieldHead formFieldHead = columnAliasMap.get(key);//字段对应别名和表
|
|
|
|
+// List<ColumnFixTrans> transColList = tableColumnFixTransMap.get(formFieldHead.getTableName());//固定值字段集合
|
|
|
|
+// List<ColumnFixTrans> currentFixValList = transColList.stream()
|
|
|
|
+// .filter(t -> t.getColName().equals(formFieldHead.getColumnName()))
|
|
|
|
+// .collect(Collectors.toList());//当前字段固定值对照值
|
|
|
|
+// if(CollectionUtils.isNotEmpty(currentFixValList)){
|
|
|
|
+// Map<String, String> valMeanMap = currentFixValList.stream()
|
|
|
|
+// .collect(Collectors.toMap(ColumnFixTrans::getColVal, ColumnFixTrans::getValMean));
|
|
|
|
+// Object value = data.get(key);
|
|
|
|
+// String mean = valMeanMap.get(value.toString());
|
|
|
|
+// valRes = mean;
|
|
|
|
+// }else{
|
|
|
|
+// //转义
|
|
|
|
+// List<String> userNameIndexes = indexMap.get("userName");
|
|
|
|
+// List<String> deptNameIndexes = indexMap.get("deptName");
|
|
|
|
+// if(1 == user.getUserNameNeedTranslate()){
|
|
|
|
+// Object value = data.get(key);
|
|
|
|
+// if (value == null) {
|
|
|
|
+// } else {
|
|
|
|
+// String val = value.toString();
|
|
|
|
+// if(wxCorpInfo!=null&&wxCorpInfo.getSaasSyncContact()==1){
|
|
|
|
+// if(CollectionUtils.isNotEmpty(userNameIndexes) && userNameIndexes.contains(key)){
|
|
|
|
+// String name = val;
|
|
|
|
+// Optional<User> first = userList.stream().filter(u -> u.getName().equals(name)).findFirst();
|
|
|
|
+// if(first.isPresent()){
|
|
|
|
+// val = "$userName="+first.get().getCorpwxUserid()+"$";
|
|
|
|
+// }else {
|
|
|
|
+// val = "";
|
|
|
|
+// }
|
|
|
|
+// }
|
|
|
|
+//
|
|
|
|
+// }
|
|
|
|
+// if(CollectionUtils.isNotEmpty(deptNameIndexes) && deptNameIndexes.contains(key)){
|
|
|
|
+// String name = val;
|
|
|
|
+// Optional<User> first = userList.stream().filter(u -> u.getName().equals(name)).findFirst();
|
|
|
|
+// if(first.isPresent()){
|
|
|
|
+// val = "$departmentName="+first.get().getCorpwxDeptid()+"$";
|
|
|
|
+// }else {
|
|
|
|
+// val = "";
|
|
|
|
+// }
|
|
|
|
+// }
|
|
|
|
+// valRes = val;
|
|
|
|
+// }
|
|
|
|
+// }else{
|
|
|
|
+// Object value = data.get(key);
|
|
|
|
+// if (value == null) {
|
|
|
|
+// valRes = "";
|
|
|
|
+// } else {
|
|
|
|
+// valRes = value.toString();
|
|
|
|
+// }
|
|
|
|
+// }
|
|
|
|
+// }
|
|
|
|
+// map.put(key,valRes);
|
|
|
|
+// }
|
|
|
|
+// resColumnList.add(map);
|
|
|
|
+// }
|
|
|
|
+// }
|
|
msg.setData(columnList);
|
|
msg.setData(columnList);
|
|
return msg;
|
|
return msg;
|
|
}
|
|
}
|
|
@@ -901,12 +1230,6 @@ public class CusTableColumnServiceImpl extends ServiceImpl<CusTableColumnMapper,
|
|
Map<String, FormFieldHead> columnAliasMap = new HashMap<>();
|
|
Map<String, FormFieldHead> columnAliasMap = new HashMap<>();
|
|
for (FormFieldHead formFieldHead : formFieldHeads) {
|
|
for (FormFieldHead formFieldHead : formFieldHeads) {
|
|
columnAliasMap.put(formFieldHead.getColumnVal(),formFieldHead);
|
|
columnAliasMap.put(formFieldHead.getColumnVal(),formFieldHead);
|
|
-// ColumnAliasVO tmpVO = new ColumnAliasVO();
|
|
|
|
-// String key = formFieldHead.getColumnVal();
|
|
|
|
-// tmpVO.setColumnCHN(key);
|
|
|
|
-// tmpVO.setColumnTblName(formFieldHead.getTableName()+"."+formFieldHead.getColumnName());
|
|
|
|
-// tmpVO.setColumnAliasName(tableNameAliasMap.get(formFieldHead.getTableName())+"."+formFieldHead.getColumnName());
|
|
|
|
-// columnAliasMap.put(key,tmpVO);
|
|
|
|
}
|
|
}
|
|
|
|
|
|
if(CollectionUtils.isNotEmpty(dataList)){
|
|
if(CollectionUtils.isNotEmpty(dataList)){
|