|
|
@@ -56,6 +56,7 @@ import org.springblade.manager.vo.*;
|
|
|
import org.springframework.dao.DataAccessException;
|
|
|
import org.springframework.jdbc.core.BeanPropertyRowMapper;
|
|
|
import org.springframework.jdbc.core.JdbcTemplate;
|
|
|
+import org.springframework.jdbc.core.SingleColumnRowMapper;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
@@ -410,13 +411,45 @@ public class TextdictInfoController extends BladeController {
|
|
|
String isExitSql = " select * from information_schema.TABLES where TABLE_NAME='" + tabName + "'";
|
|
|
List<Map<String, Object>> tablist = jdbcTemplate.queryForList(isExitSql);
|
|
|
if (tablist != null && tablist.size() > 0 && wbsTreePrivate.getType() != 10) {
|
|
|
+ String textType = textdictInfo.getTextId();
|
|
|
+ int type = 0;
|
|
|
+ if (textType.equals("daterange") || textType.equals("selectBox")) {
|
|
|
+ type = 1;
|
|
|
+ }
|
|
|
String[] split = keyname.split("__");
|
|
|
- String clarSql = "update " + tabName + " set " + split[0] + "=null where p_key_id in(SELECT p_key_id FROM m_wbs_tree_contract WHERE is_type_private_pid ='" + wbsTreePrivate.getPKeyId() + "' and project_id='" + wbsTreePrivate.getProjectId() + "'UNION ALL SELECT 1 )";
|
|
|
- if (split.length > 1 && StringUtil.isNumeric(split[1]) && Integer.parseInt(split[1]) > 80) {
|
|
|
- clarSql = "update " + tabName + " set key_201 = REPLACE(key_201, '" + split[0] + ":' , ':') where p_key_id in(SELECT p_key_id FROM m_wbs_tree_contract WHERE is_type_private_pid ='" + wbsTreePrivate.getPKeyId() + "' and project_id='" + wbsTreePrivate.getProjectId() + "'UNION ALL SELECT 1 )";
|
|
|
+ List<String> query = jdbcTemplate.query("SELECT column_name from information_schema.COLUMNS where table_name = '" + tabName + "' and column_name in ( '" + split[0] + "', 'key_201')", new SingleColumnRowMapper<>(String.class));
|
|
|
+ String sql = "";
|
|
|
+ if (!query.isEmpty()) {
|
|
|
+ String value;
|
|
|
+ if (type == 1) {
|
|
|
+ // 转数组格式
|
|
|
+ value = String.format(" %s = if(substr(%s,1,1) = '[', %s, concat('[', @v := substr(%s,1, if(instr(%s, '_^_') - 1 < 0, char_length(%s), instr(%s, '_^_') - 1)), if(instr(@v,',') > 0, '', concat(',',@v)) ,']', substr(%s, instr(%s, '_^_'))))", split[0], split[0], split[0], split[0], split[0], split[0], split[0], split[0], split[0]);
|
|
|
+ } else {
|
|
|
+ // 转普通格式
|
|
|
+ value = String.format(" %s = if(substr(%s,1,1) = '[', concat(substr(%s, instr(%s, '[') + 1, (CHAR_LENGTH(%s) - instr(REVERSE(%s) , ']') - instr(%s, '['))), substr(%s, instr(%s, '_^_'))), %s)",
|
|
|
+ split[0], split[0], split[0], split[0], split[0], split[0], split[0], split[0], split[0], split[0]);
|
|
|
+ }
|
|
|
+ if (query.contains("key_201")) {
|
|
|
+ String value1;
|
|
|
+ if (type == 1) {
|
|
|
+ // 转数组格式
|
|
|
+ value1 = String.format(" key_201 = concat(SUBSTRING_INDEX(key_201,'%s:',1), '%s:', if(substr(@v := if(INSTR(SUBSTRING_INDEX(key_201, '%s:',-1),'$$') - 1 < 0, SUBSTRING_INDEX(key_201, '%s:',-1), SUBSTR(SUBSTRING_INDEX(key_201, '%s:',-1), 1 , INSTR(SUBSTRING_INDEX(key_201, '%s:',-1),'$$') - 1)) , 1, 1) = '[', @v, concat('[', @vv := substr(@v,1, if(instr(@v, '_^_') - 1 < 0, char_length(@v), instr(@v, '_^_') - 1), if(instr(@vv,',') > 0, '', concat(',',@vv)) ,']', substr(@v, instr(@v, '_^_')))) , if (INSTR(SUBSTRING_INDEX(key_201, 'key_16:',-1),'$$') - 1 < 0, '', concat('$$', SUBSTRING_INDEX(SUBSTRING_INDEX(key_201,'key_16:',-1),'$$',-1))) ) ",
|
|
|
+ split[0],split[0], split[0], split[0], split[0], split[0]);
|
|
|
+ } else {
|
|
|
+ // 转普通格式
|
|
|
+ value1 = String.format(" key_201 = concat(SUBSTRING_INDEX(key_201,'%s:',1), '%s:', if(substr(@v := if(INSTR(SUBSTRING_INDEX(key_201, '%s:',-1),'$$') - 1 < 0, SUBSTRING_INDEX(key_201, '%s:',-1), SUBSTR(SUBSTRING_INDEX(key_201, '%s:',-1), 1 , INSTR(SUBSTRING_INDEX(key_201, '%s:',-1),'$$') - 1)) , 1, 1) != '[', @v, concat(substr(@v, instr(@v, '[') + 1, (CHAR_LENGTH(@v) - instr(REVERSE(@v) , ']') - instr(@v, '['))), substr(@v, instr(@v, '_^_')))) , if (INSTR(SUBSTRING_INDEX(key_201, 'key_16:',-1),'$$') - 1 < 0, '', concat('$$', SUBSTRING_INDEX(SUBSTRING_INDEX(key_201,'key_16:',-1),'$$',-1))) ) ",
|
|
|
+ split[0],split[0],split[0],split[0],split[0], split[0]);
|
|
|
+ }
|
|
|
+ value = value + " , " + value1;
|
|
|
+ sql = String.format("update %s set %s where p_key_id in ( select p_key_id from m_wbs_tree_contract WHERE is_type_private_pid = %d and project_id = %s )",
|
|
|
+ tabName, value ,wbsTreePrivate.getPKeyId(), wbsTreePrivate.getProjectId());
|
|
|
+ } else {
|
|
|
+ sql = String.format("update %s set %s where p_key_id in ( select p_key_id from m_wbs_tree_contract WHERE is_type_private_pid = %d and project_id = %s ) and %s is not null and %s != ''",
|
|
|
+ tabName, value ,wbsTreePrivate.getPKeyId(), wbsTreePrivate.getProjectId(), split[0], split[0]);
|
|
|
+ }
|
|
|
}
|
|
|
try {
|
|
|
- jdbcTemplate.execute(clarSql);
|
|
|
+ jdbcTemplate.execute(sql);
|
|
|
} catch (DataAccessException e) {
|
|
|
e.printStackTrace();
|
|
|
}
|