|
|
|
|
@ -1,307 +1,307 @@
|
|
|
|
|
/* */ package com.archive.project.dasz.physicaltablecolumn.service.impl;
|
|
|
|
|
/* */
|
|
|
|
|
/* */ import com.archive.common.archiveUtil.SqlLiteUtil;
|
|
|
|
|
/* */ import com.archive.common.archiveUtil.TableUtil;
|
|
|
|
|
/* */ import com.archive.common.utils.StringUtils;
|
|
|
|
|
/* */ import com.archive.common.utils.text.Convert;
|
|
|
|
|
/* */ import com.archive.framework.config.ArchiveConfig;
|
|
|
|
|
/* */ import com.archive.project.common.service.IExecuteSqlService;
|
|
|
|
|
/* */ import com.archive.project.dasz.physicaltable.service.IPhysicalTableService;
|
|
|
|
|
/* */ import com.archive.project.dasz.physicaltablecolumn.domain.PhysicalTableColumn;
|
|
|
|
|
/* */ import com.archive.project.dasz.physicaltablecolumn.mapper.PhysicalTableColumnMapper;
|
|
|
|
|
/* */ import com.archive.project.dasz.physicaltablecolumn.service.IPhysicalTableColumnService;
|
|
|
|
|
/* */ import java.util.List;
|
|
|
|
|
/* */ import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
/* */ import org.springframework.stereotype.Service;
|
|
|
|
|
/* */ import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
/* */
|
|
|
|
|
/* */
|
|
|
|
|
/* */
|
|
|
|
|
/* */
|
|
|
|
|
/* */
|
|
|
|
|
/* */
|
|
|
|
|
/* */
|
|
|
|
|
/* */
|
|
|
|
|
/* */
|
|
|
|
|
/* */
|
|
|
|
|
/* */
|
|
|
|
|
/* */
|
|
|
|
|
/* */
|
|
|
|
|
/* */
|
|
|
|
|
/* */
|
|
|
|
|
/* */
|
|
|
|
|
/* */
|
|
|
|
|
/* */
|
|
|
|
|
/* */
|
|
|
|
|
/* */
|
|
|
|
|
/* */ @Service
|
|
|
|
|
/* */ public class PhysicalTableColumnServiceImpl
|
|
|
|
|
/* */ implements IPhysicalTableColumnService
|
|
|
|
|
/* */ {
|
|
|
|
|
/* */ @Autowired
|
|
|
|
|
/* */ private PhysicalTableColumnMapper physicalTableColumnMapper;
|
|
|
|
|
/* */ @Autowired
|
|
|
|
|
/* */ private IExecuteSqlService executeSqlService;
|
|
|
|
|
/* */ @Autowired
|
|
|
|
|
/* */ private IPhysicalTableService physicalTableService;
|
|
|
|
|
/* */ @Autowired
|
|
|
|
|
/* */ private ArchiveConfig archiveConfig;
|
|
|
|
|
/* */
|
|
|
|
|
/* */ public PhysicalTableColumn selectPhysicalTableColumnById(Long id) {
|
|
|
|
|
/* 51 */ return this.physicalTableColumnMapper.selectPhysicalTableColumnById(id);
|
|
|
|
|
/* */ }
|
|
|
|
|
/* */
|
|
|
|
|
/* */
|
|
|
|
|
/* */
|
|
|
|
|
/* */
|
|
|
|
|
/* */
|
|
|
|
|
/* */
|
|
|
|
|
/* */
|
|
|
|
|
/* */
|
|
|
|
|
/* */
|
|
|
|
|
/* */ public List<PhysicalTableColumn> selectPhysicalTableColumnList(PhysicalTableColumn physicalTableColumn) {
|
|
|
|
|
/* 63 */ if ("mysql".equals(this.archiveConfig.getDatabaseType())) {
|
|
|
|
|
/* 64 */ return this.physicalTableColumnMapper.selectPhysicalTableColumnListMysql(physicalTableColumn);
|
|
|
|
|
/* */ }
|
|
|
|
|
/* 66 */ return this.physicalTableColumnMapper.selectPhysicalTableColumnListSqlLite(physicalTableColumn);
|
|
|
|
|
/* */ }
|
|
|
|
|
/* */
|
|
|
|
|
/* */
|
|
|
|
|
/* */
|
|
|
|
|
/* */
|
|
|
|
|
/* */
|
|
|
|
|
/* */
|
|
|
|
|
/* */
|
|
|
|
|
/* */
|
|
|
|
|
/* */
|
|
|
|
|
/* */
|
|
|
|
|
/* */
|
|
|
|
|
/* */ @Transactional
|
|
|
|
|
/* */ public void insertPhysicalTableColumn(PhysicalTableColumn physicalTableColumn, boolean isCreatArchiveType) throws Exception {
|
|
|
|
|
/* 81 */ if (!isCreatArchiveType) {
|
|
|
|
|
/* 82 */ String tableName = TableUtil.getTableName(physicalTableColumn.getTableId());
|
|
|
|
|
/* 83 */ String sql = "ALTER TABLE " + tableName + " ADD COLUMN `" + physicalTableColumn.getColumnCode() + "` ";
|
|
|
|
|
/* */
|
|
|
|
|
/* 85 */ String columnType = physicalTableColumn.getColumnType();
|
|
|
|
|
/* 86 */ switch (columnType) {
|
|
|
|
|
/* */ case "D":
|
|
|
|
|
/* 88 */ if ("mysql".equals(this.archiveConfig.getDatabaseType())) {
|
|
|
|
|
/* 89 */ columnType = " varchar(" + physicalTableColumn.getColumnLength() + ") "; break;
|
|
|
|
|
/* 90 */ } if ("sqlite".equals(this.archiveConfig.getDatabaseType())) {
|
|
|
|
|
/* 91 */ columnType = " text(" + physicalTableColumn.getColumnLength() + ") ";
|
|
|
|
|
/* */ }
|
|
|
|
|
/* */ break;
|
|
|
|
|
/* */ case "S":
|
|
|
|
|
/* 95 */ if ("mysql".equals(this.archiveConfig.getDatabaseType())) {
|
|
|
|
|
/* 96 */ columnType = " varchar(" + physicalTableColumn.getColumnLength() + ") "; break;
|
|
|
|
|
/* 97 */ } if ("sqlite".equals(this.archiveConfig.getDatabaseType())) {
|
|
|
|
|
/* 98 */ columnType = " text(" + physicalTableColumn.getColumnLength() + ") ";
|
|
|
|
|
/* */ }
|
|
|
|
|
/* */ break;
|
|
|
|
|
/* */ case "C":
|
|
|
|
|
/* 102 */ if ("mysql".equals(this.archiveConfig.getDatabaseType())) {
|
|
|
|
|
/* 103 */ columnType = " int "; break;
|
|
|
|
|
/* 104 */ } if ("sqlite".equals(this.archiveConfig.getDatabaseType())) {
|
|
|
|
|
/* 105 */ columnType = " INTEGER ";
|
|
|
|
|
/* */ }
|
|
|
|
|
/* */ break;
|
|
|
|
|
/* */ }
|
|
|
|
|
/* 109 */ sql = sql + columnType;
|
|
|
|
|
/* 110 */ if ("mysql".equals(this.archiveConfig.getDatabaseType())) {
|
|
|
|
|
/* 111 */ if (StringUtils.isEmpty(physicalTableColumn.getMrz())) {
|
|
|
|
|
/* 112 */ sql = sql + " COMMENT '" + physicalTableColumn.getColumnName() + "'";
|
|
|
|
|
/* */ } else {
|
|
|
|
|
/* 114 */ sql = sql + " DEFAULT '" + physicalTableColumn.getMrz() + "' COMMENT '" + physicalTableColumn.getColumnName() + "'";
|
|
|
|
|
/* */ }
|
|
|
|
|
/* 116 */ } else if ("sqlite".equals(this.archiveConfig.getDatabaseType())) {
|
|
|
|
|
/* */
|
|
|
|
|
/* 118 */ if (StringUtils.isNotEmpty(physicalTableColumn.getMrz())) {
|
|
|
|
|
/* 119 */ sql = sql + " DEFAULT '" + physicalTableColumn.getMrz() + "'";
|
|
|
|
|
/* */ }
|
|
|
|
|
/* */ }
|
|
|
|
|
/* */
|
|
|
|
|
/* 123 */ this.executeSqlService.jdbcTemplateExecute(sql);
|
|
|
|
|
/* */ }
|
|
|
|
|
/* 125 */ this.physicalTableColumnMapper.insertPhysicalTableColumn(physicalTableColumn);
|
|
|
|
|
/* */ }
|
|
|
|
|
/* */
|
|
|
|
|
/* */
|
|
|
|
|
/* */
|
|
|
|
|
/* */
|
|
|
|
|
/* */
|
|
|
|
|
/* */
|
|
|
|
|
/* */
|
|
|
|
|
/* */
|
|
|
|
|
/* */
|
|
|
|
|
/* */ @Transactional
|
|
|
|
|
/* */ public void updatePhysicalTableColumn(PhysicalTableColumn physicalTableColumn) throws Exception {
|
|
|
|
|
/* 138 */ String tableName = TableUtil.getTableName(physicalTableColumn.getTableId());
|
|
|
|
|
/* 139 */ String sql = "ALTER TABLE " + tableName + " MODIFY COLUMN " + physicalTableColumn.getColumnCode();
|
|
|
|
|
/* */
|
|
|
|
|
/* 141 */ String columnType = physicalTableColumn.getColumnType();
|
|
|
|
|
/* 142 */ switch (columnType) {
|
|
|
|
|
/* */ case "D":
|
|
|
|
|
/* 144 */ if ("mysql".equals(this.archiveConfig.getDatabaseType())) {
|
|
|
|
|
/* 145 */ columnType = " varchar(" + physicalTableColumn.getColumnLength() + ") ";
|
|
|
|
|
/* */ }
|
|
|
|
|
/* */ break;
|
|
|
|
|
/* */ case "S":
|
|
|
|
|
/* 149 */ if ("mysql".equals(this.archiveConfig.getDatabaseType())) {
|
|
|
|
|
/* 150 */ columnType = " varchar(" + physicalTableColumn.getColumnLength() + ") "; break;
|
|
|
|
|
/* 151 */ } if ("sqlite".equals(this.archiveConfig.getDatabaseType())) {
|
|
|
|
|
/* 152 */ columnType = " text(" + physicalTableColumn.getColumnLength() + ") ";
|
|
|
|
|
/* */ }
|
|
|
|
|
/* */ break;
|
|
|
|
|
/* */ case "C":
|
|
|
|
|
/* 156 */ if ("mysql".equals(this.archiveConfig.getDatabaseType())) {
|
|
|
|
|
/* 157 */ columnType = " int "; break;
|
|
|
|
|
/* 158 */ } if ("sqlite".equals(this.archiveConfig.getDatabaseType())) {
|
|
|
|
|
/* 159 */ columnType = " INTEGER ";
|
|
|
|
|
/* */ }
|
|
|
|
|
/* */ break;
|
|
|
|
|
/* */ }
|
|
|
|
|
/* 163 */ sql = sql + columnType;
|
|
|
|
|
/* 164 */ if ("mysql".equals(this.archiveConfig.getDatabaseType())) {
|
|
|
|
|
/* 165 */ if (StringUtils.isEmpty(physicalTableColumn.getMrz())) {
|
|
|
|
|
/* 166 */ sql = sql + " COMMENT '" + physicalTableColumn.getColumnName() + "'";
|
|
|
|
|
/* */ } else {
|
|
|
|
|
/* 168 */ sql = sql + " DEFAULT '" + physicalTableColumn.getMrz() + "' COMMENT '" + physicalTableColumn.getColumnName() + "'";
|
|
|
|
|
/* */ }
|
|
|
|
|
/* */ }
|
|
|
|
|
/* 171 */ this.executeSqlService.jdbcTemplateExecute(sql);
|
|
|
|
|
/* 172 */ this.physicalTableColumnMapper.updatePhysicalTableColumn(physicalTableColumn);
|
|
|
|
|
/* */ }
|
|
|
|
|
/* */
|
|
|
|
|
/* */
|
|
|
|
|
/* */
|
|
|
|
|
/* */
|
|
|
|
|
/* */
|
|
|
|
|
/* */
|
|
|
|
|
/* */
|
|
|
|
|
/* */
|
|
|
|
|
/* */
|
|
|
|
|
/* */
|
|
|
|
|
/* */ @Transactional
|
|
|
|
|
/* */ public void updatePhysicalTableColumnSqlite(PhysicalTableColumn physicalTableColumn) throws Exception {
|
|
|
|
|
/* 186 */ String tableName = TableUtil.getTableName(physicalTableColumn.getTableId());
|
|
|
|
|
/* */
|
|
|
|
|
/* */
|
|
|
|
|
/* */
|
|
|
|
|
/* */
|
|
|
|
|
/* 191 */ PhysicalTableColumn ptc = this.physicalTableColumnMapper.selectPhysicalTableColumnById(physicalTableColumn.getId());
|
|
|
|
|
/* 192 */ String newType = "";
|
|
|
|
|
/* 193 */ String newMrz = "";
|
|
|
|
|
/* */
|
|
|
|
|
/* 195 */ if (!physicalTableColumn.getColumnType().equals(ptc.getColumnType()))
|
|
|
|
|
/* */ {
|
|
|
|
|
/* 197 */ if (physicalTableColumn.getColumnType().equals("C")) {
|
|
|
|
|
/* 198 */ newType = "INTEGER";
|
|
|
|
|
/* */ } else {
|
|
|
|
|
/* 200 */ newType = "TEXT";
|
|
|
|
|
/* */ }
|
|
|
|
|
/* */ }
|
|
|
|
|
/* */
|
|
|
|
|
/* 204 */ if (!physicalTableColumn.getMrz().equals(ptc.getMrz()))
|
|
|
|
|
/* */ {
|
|
|
|
|
/* 206 */ newMrz = ptc.getMrz();
|
|
|
|
|
/* */ }
|
|
|
|
|
/* */
|
|
|
|
|
/* 209 */ if (!newType.equals("") || !newMrz.equals("")) {
|
|
|
|
|
/* 210 */ SqlLiteUtil.updateColumnType(tableName, physicalTableColumn.getColumnType(), physicalTableColumn.getColumnCode(), newMrz);
|
|
|
|
|
/* */ }
|
|
|
|
|
/* 212 */ this.physicalTableColumnMapper.updatePhysicalTableColumn(physicalTableColumn);
|
|
|
|
|
/* */ }
|
|
|
|
|
/* */
|
|
|
|
|
/* */
|
|
|
|
|
/* */
|
|
|
|
|
/* */
|
|
|
|
|
/* */
|
|
|
|
|
/* */
|
|
|
|
|
/* */
|
|
|
|
|
/* */
|
|
|
|
|
/* */ @Transactional
|
|
|
|
|
/* */ public void deletePhysicalTableColumnByIds(String ids) throws Exception {
|
|
|
|
|
/* 224 */ Long id = Long.valueOf(Long.parseLong(ids));
|
|
|
|
|
/* 225 */ PhysicalTableColumn physicalTableColumn = this.physicalTableColumnMapper.selectPhysicalTableColumnById(id);
|
|
|
|
|
/* 226 */ String tableName = TableUtil.getTableName(physicalTableColumn.getTableId());
|
|
|
|
|
/* 227 */ String columnCode = physicalTableColumn.getColumnCode();
|
|
|
|
|
/* 228 */ String sql = "ALTER TABLE " + tableName + " DROP COLUMN " + columnCode;
|
|
|
|
|
/* 229 */ this.executeSqlService.jdbcTemplateExecute(sql);
|
|
|
|
|
/* 230 */ this.physicalTableColumnMapper.deletePhysicalTableColumnByIds(Convert.toStrArray(ids));
|
|
|
|
|
/* */
|
|
|
|
|
/* */
|
|
|
|
|
/* 233 */ for (String colId : Convert.toStrArray(ids)) {
|
|
|
|
|
/* 234 */ this.physicalTableService.removeTableFormByColumnId(Long.valueOf(Long.parseLong(colId)));
|
|
|
|
|
/* */ }
|
|
|
|
|
/* */ }
|
|
|
|
|
/* */
|
|
|
|
|
/* */
|
|
|
|
|
/* */
|
|
|
|
|
/* */
|
|
|
|
|
/* */
|
|
|
|
|
/* */
|
|
|
|
|
/* */
|
|
|
|
|
/* */
|
|
|
|
|
/* */
|
|
|
|
|
/* */ @Transactional
|
|
|
|
|
/* */ public void deletePhysicalTableColumnByIdsSqlLite(String ids) throws Exception {
|
|
|
|
|
/* 248 */ Long id = Long.valueOf(Long.parseLong(ids));
|
|
|
|
|
/* 249 */ PhysicalTableColumn physicalTableColumn = this.physicalTableColumnMapper.selectPhysicalTableColumnById(id);
|
|
|
|
|
/* 250 */ String tableName = TableUtil.getTableName(physicalTableColumn.getTableId());
|
|
|
|
|
/* 251 */ String columnCode = physicalTableColumn.getColumnCode();
|
|
|
|
|
/* 252 */ SqlLiteUtil.deleteColumn(tableName, columnCode);
|
|
|
|
|
/* */
|
|
|
|
|
/* 254 */ this.physicalTableColumnMapper.deletePhysicalTableColumnByIds(Convert.toStrArray(ids));
|
|
|
|
|
/* */
|
|
|
|
|
/* */
|
|
|
|
|
/* 257 */ for (String colId : Convert.toStrArray(ids)) {
|
|
|
|
|
/* 258 */ this.physicalTableService.removeTableFormByColumnId(Long.valueOf(Long.parseLong(colId)));
|
|
|
|
|
/* */ }
|
|
|
|
|
/* */ }
|
|
|
|
|
/* */
|
|
|
|
|
/* */
|
|
|
|
|
/* */
|
|
|
|
|
/* */
|
|
|
|
|
/* */
|
|
|
|
|
/* */
|
|
|
|
|
/* */
|
|
|
|
|
/* */
|
|
|
|
|
/* */
|
|
|
|
|
/* */ public int deletePhysicalTableColumnById(Long id) {
|
|
|
|
|
/* 271 */ return this.physicalTableColumnMapper.deletePhysicalTableColumnById(id);
|
|
|
|
|
/* */ }
|
|
|
|
|
/* */
|
|
|
|
|
/* */
|
|
|
|
|
/* */ @Transactional
|
|
|
|
|
/* */ public void updateSetStatus(Long id, String type, Long status) throws Exception {
|
|
|
|
|
/* 277 */ String sql = "update t_xtpz_physical_table_column set " + type + " = " + status + " where id = " + id;
|
|
|
|
|
/* 278 */ this.executeSqlService.jdbcTemplateExecute(sql);
|
|
|
|
|
/* */
|
|
|
|
|
/* 280 */ if ("jmx".equals(type) && status.longValue() == 0L) {
|
|
|
|
|
/* 281 */ this.physicalTableService.removeTableFormByColumnId(id);
|
|
|
|
|
/* */ }
|
|
|
|
|
/* */ }
|
|
|
|
|
/* */
|
|
|
|
|
/* */
|
|
|
|
|
/* */
|
|
|
|
|
/* */
|
|
|
|
|
/* */
|
|
|
|
|
/* */
|
|
|
|
|
/* */
|
|
|
|
|
/* */
|
|
|
|
|
/* */
|
|
|
|
|
/* */ public String getColumnCodeByTableIdAndShowName(String columnShowName, long tableId) {
|
|
|
|
|
/* 294 */ String res = "";
|
|
|
|
|
/* 295 */ PhysicalTableColumn physicalTableColumn = new PhysicalTableColumn();
|
|
|
|
|
/* 296 */ physicalTableColumn.setTableId(Long.valueOf(tableId));
|
|
|
|
|
/* 297 */ physicalTableColumn.setColumnName(columnShowName);
|
|
|
|
|
/* 298 */ List<PhysicalTableColumn> list = selectPhysicalTableColumnList(physicalTableColumn);
|
|
|
|
|
/* 299 */ if (list.size() > 0 && list.get(0) != null) {
|
|
|
|
|
/* 300 */ res = ((PhysicalTableColumn)list.get(0)).getColumnCode();
|
|
|
|
|
/* */ }
|
|
|
|
|
/* 302 */ return res;
|
|
|
|
|
/* */ }
|
|
|
|
|
/* */ }
|
|
|
|
|
package com.archive.project.dasz.physicaltablecolumn.service.impl;
|
|
|
|
|
|
|
|
|
|
import com.archive.common.archiveUtil.SqlLiteUtil;
|
|
|
|
|
import com.archive.common.archiveUtil.TableUtil;
|
|
|
|
|
import com.archive.common.utils.StringUtils;
|
|
|
|
|
import com.archive.common.utils.text.Convert;
|
|
|
|
|
import com.archive.framework.config.ArchiveConfig;
|
|
|
|
|
import com.archive.project.common.service.IExecuteSqlService;
|
|
|
|
|
import com.archive.project.dasz.physicaltable.service.IPhysicalTableService;
|
|
|
|
|
import com.archive.project.dasz.physicaltablecolumn.domain.PhysicalTableColumn;
|
|
|
|
|
import com.archive.project.dasz.physicaltablecolumn.mapper.PhysicalTableColumnMapper;
|
|
|
|
|
import com.archive.project.dasz.physicaltablecolumn.service.IPhysicalTableColumnService;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Service
|
|
|
|
|
public class PhysicalTableColumnServiceImpl
|
|
|
|
|
implements IPhysicalTableColumnService
|
|
|
|
|
{
|
|
|
|
|
@Autowired
|
|
|
|
|
private PhysicalTableColumnMapper physicalTableColumnMapper;
|
|
|
|
|
@Autowired
|
|
|
|
|
private IExecuteSqlService executeSqlService;
|
|
|
|
|
@Autowired
|
|
|
|
|
private IPhysicalTableService physicalTableService;
|
|
|
|
|
@Autowired
|
|
|
|
|
private ArchiveConfig archiveConfig;
|
|
|
|
|
|
|
|
|
|
public PhysicalTableColumn selectPhysicalTableColumnById(Long id) {
|
|
|
|
|
return this.physicalTableColumnMapper.selectPhysicalTableColumnById(id);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public List<PhysicalTableColumn> selectPhysicalTableColumnList(PhysicalTableColumn physicalTableColumn) {
|
|
|
|
|
if ("mysql".equals(this.archiveConfig.getDatabaseType())) {
|
|
|
|
|
return this.physicalTableColumnMapper.selectPhysicalTableColumnListMysql(physicalTableColumn);
|
|
|
|
|
}
|
|
|
|
|
return this.physicalTableColumnMapper.selectPhysicalTableColumnListSqlLite(physicalTableColumn);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Transactional
|
|
|
|
|
public void insertPhysicalTableColumn(PhysicalTableColumn physicalTableColumn, boolean isCreatArchiveType) throws Exception {
|
|
|
|
|
if (!isCreatArchiveType) {
|
|
|
|
|
String tableName = TableUtil.getTableName(physicalTableColumn.getTableId());
|
|
|
|
|
String sql = "ALTER TABLE " + tableName + " ADD COLUMN `" + physicalTableColumn.getColumnCode() + "` ";
|
|
|
|
|
|
|
|
|
|
String columnType = physicalTableColumn.getColumnType();
|
|
|
|
|
switch (columnType) {
|
|
|
|
|
case "D":
|
|
|
|
|
if ("mysql".equals(this.archiveConfig.getDatabaseType())) {
|
|
|
|
|
columnType = " varchar(" + physicalTableColumn.getColumnLength() + ") "; break;
|
|
|
|
|
} if ("sqlite".equals(this.archiveConfig.getDatabaseType())) {
|
|
|
|
|
columnType = " text(" + physicalTableColumn.getColumnLength() + ") ";
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case "S":
|
|
|
|
|
if ("mysql".equals(this.archiveConfig.getDatabaseType())) {
|
|
|
|
|
columnType = " varchar(" + physicalTableColumn.getColumnLength() + ") "; break;
|
|
|
|
|
} if ("sqlite".equals(this.archiveConfig.getDatabaseType())) {
|
|
|
|
|
columnType = " text(" + physicalTableColumn.getColumnLength() + ") ";
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case "C":
|
|
|
|
|
if ("mysql".equals(this.archiveConfig.getDatabaseType())) {
|
|
|
|
|
columnType = " int "; break;
|
|
|
|
|
} if ("sqlite".equals(this.archiveConfig.getDatabaseType())) {
|
|
|
|
|
columnType = " INTEGER ";
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
sql = sql + columnType;
|
|
|
|
|
if ("mysql".equals(this.archiveConfig.getDatabaseType())) {
|
|
|
|
|
if (StringUtils.isEmpty(physicalTableColumn.getMrz())) {
|
|
|
|
|
sql = sql + " COMMENT '" + physicalTableColumn.getColumnName() + "'";
|
|
|
|
|
} else {
|
|
|
|
|
sql = sql + " DEFAULT '" + physicalTableColumn.getMrz() + "' COMMENT '" + physicalTableColumn.getColumnName() + "'";
|
|
|
|
|
}
|
|
|
|
|
} else if ("sqlite".equals(this.archiveConfig.getDatabaseType())) {
|
|
|
|
|
|
|
|
|
|
if (StringUtils.isNotEmpty(physicalTableColumn.getMrz())) {
|
|
|
|
|
sql = sql + " DEFAULT '" + physicalTableColumn.getMrz() + "'";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
this.executeSqlService.jdbcTemplateExecute(sql);
|
|
|
|
|
}
|
|
|
|
|
this.physicalTableColumnMapper.insertPhysicalTableColumn(physicalTableColumn);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Transactional
|
|
|
|
|
public void updatePhysicalTableColumn(PhysicalTableColumn physicalTableColumn) throws Exception {
|
|
|
|
|
String tableName = TableUtil.getTableName(physicalTableColumn.getTableId());
|
|
|
|
|
String sql = "ALTER TABLE " + tableName + " MODIFY COLUMN " + physicalTableColumn.getColumnCode();
|
|
|
|
|
|
|
|
|
|
String columnType = physicalTableColumn.getColumnType();
|
|
|
|
|
switch (columnType) {
|
|
|
|
|
case "D":
|
|
|
|
|
if ("mysql".equals(this.archiveConfig.getDatabaseType())) {
|
|
|
|
|
columnType = " varchar(" + physicalTableColumn.getColumnLength() + ") ";
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case "S":
|
|
|
|
|
if ("mysql".equals(this.archiveConfig.getDatabaseType())) {
|
|
|
|
|
columnType = " varchar(" + physicalTableColumn.getColumnLength() + ") "; break;
|
|
|
|
|
} if ("sqlite".equals(this.archiveConfig.getDatabaseType())) {
|
|
|
|
|
columnType = " text(" + physicalTableColumn.getColumnLength() + ") ";
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case "C":
|
|
|
|
|
if ("mysql".equals(this.archiveConfig.getDatabaseType())) {
|
|
|
|
|
columnType = " int "; break;
|
|
|
|
|
} if ("sqlite".equals(this.archiveConfig.getDatabaseType())) {
|
|
|
|
|
columnType = " INTEGER ";
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
sql = sql + columnType;
|
|
|
|
|
if ("mysql".equals(this.archiveConfig.getDatabaseType())) {
|
|
|
|
|
if (StringUtils.isEmpty(physicalTableColumn.getMrz())) {
|
|
|
|
|
sql = sql + " COMMENT '" + physicalTableColumn.getColumnName() + "'";
|
|
|
|
|
} else {
|
|
|
|
|
sql = sql + " DEFAULT '" + physicalTableColumn.getMrz() + "' COMMENT '" + physicalTableColumn.getColumnName() + "'";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
this.executeSqlService.jdbcTemplateExecute(sql);
|
|
|
|
|
this.physicalTableColumnMapper.updatePhysicalTableColumn(physicalTableColumn);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Transactional
|
|
|
|
|
public void updatePhysicalTableColumnSqlite(PhysicalTableColumn physicalTableColumn) throws Exception {
|
|
|
|
|
String tableName = TableUtil.getTableName(physicalTableColumn.getTableId());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
PhysicalTableColumn ptc = this.physicalTableColumnMapper.selectPhysicalTableColumnById(physicalTableColumn.getId());
|
|
|
|
|
String newType = "";
|
|
|
|
|
String newMrz = "";
|
|
|
|
|
|
|
|
|
|
if (!physicalTableColumn.getColumnType().equals(ptc.getColumnType()))
|
|
|
|
|
{
|
|
|
|
|
if (physicalTableColumn.getColumnType().equals("C")) {
|
|
|
|
|
newType = "INTEGER";
|
|
|
|
|
} else {
|
|
|
|
|
newType = "TEXT";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!physicalTableColumn.getMrz().equals(ptc.getMrz()))
|
|
|
|
|
{
|
|
|
|
|
newMrz = ptc.getMrz();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!newType.equals("") || !newMrz.equals("")) {
|
|
|
|
|
SqlLiteUtil.updateColumnType(tableName, physicalTableColumn.getColumnType(), physicalTableColumn.getColumnCode(), newMrz);
|
|
|
|
|
}
|
|
|
|
|
this.physicalTableColumnMapper.updatePhysicalTableColumn(physicalTableColumn);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Transactional
|
|
|
|
|
public void deletePhysicalTableColumnByIds(String ids) throws Exception {
|
|
|
|
|
Long id = Long.valueOf(Long.parseLong(ids));
|
|
|
|
|
PhysicalTableColumn physicalTableColumn = this.physicalTableColumnMapper.selectPhysicalTableColumnById(id);
|
|
|
|
|
String tableName = TableUtil.getTableName(physicalTableColumn.getTableId());
|
|
|
|
|
String columnCode = physicalTableColumn.getColumnCode();
|
|
|
|
|
String sql = "ALTER TABLE " + tableName + " DROP COLUMN " + columnCode;
|
|
|
|
|
this.executeSqlService.jdbcTemplateExecute(sql);
|
|
|
|
|
this.physicalTableColumnMapper.deletePhysicalTableColumnByIds(Convert.toStrArray(ids));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (String colId : Convert.toStrArray(ids)) {
|
|
|
|
|
this.physicalTableService.removeTableFormByColumnId(Long.valueOf(Long.parseLong(colId)));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Transactional
|
|
|
|
|
public void deletePhysicalTableColumnByIdsSqlLite(String ids) throws Exception {
|
|
|
|
|
Long id = Long.valueOf(Long.parseLong(ids));
|
|
|
|
|
PhysicalTableColumn physicalTableColumn = this.physicalTableColumnMapper.selectPhysicalTableColumnById(id);
|
|
|
|
|
String tableName = TableUtil.getTableName(physicalTableColumn.getTableId());
|
|
|
|
|
String columnCode = physicalTableColumn.getColumnCode();
|
|
|
|
|
SqlLiteUtil.deleteColumn(tableName, columnCode);
|
|
|
|
|
|
|
|
|
|
this.physicalTableColumnMapper.deletePhysicalTableColumnByIds(Convert.toStrArray(ids));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (String colId : Convert.toStrArray(ids)) {
|
|
|
|
|
this.physicalTableService.removeTableFormByColumnId(Long.valueOf(Long.parseLong(colId)));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public int deletePhysicalTableColumnById(Long id) {
|
|
|
|
|
return this.physicalTableColumnMapper.deletePhysicalTableColumnById(id);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Transactional
|
|
|
|
|
public void updateSetStatus(Long id, String type, Long status) throws Exception {
|
|
|
|
|
String sql = "update t_xtpz_physical_table_column set " + type + " = " + status + " where id = " + id;
|
|
|
|
|
this.executeSqlService.jdbcTemplateExecute(sql);
|
|
|
|
|
|
|
|
|
|
if ("jmx".equals(type) && status.longValue() == 0L) {
|
|
|
|
|
this.physicalTableService.removeTableFormByColumnId(id);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public String getColumnCodeByTableIdAndShowName(String columnShowName, long tableId) {
|
|
|
|
|
String res = "";
|
|
|
|
|
PhysicalTableColumn physicalTableColumn = new PhysicalTableColumn();
|
|
|
|
|
physicalTableColumn.setTableId(Long.valueOf(tableId));
|
|
|
|
|
physicalTableColumn.setColumnName(columnShowName);
|
|
|
|
|
List<PhysicalTableColumn> list = selectPhysicalTableColumnList(physicalTableColumn);
|
|
|
|
|
if (list.size() > 0 && list.get(0) != null) {
|
|
|
|
|
res = ((PhysicalTableColumn)list.get(0)).getColumnCode();
|
|
|
|
|
}
|
|
|
|
|
return res;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Location: C:\Users\Administrator\Desktop\extracted.zip!\extracted\BOOT-INF\classes\com\archive\project\dasz\physicaltablecolumn\service\impl\PhysicalTableColumnServiceImpl.class
|
|
|
|
|
|