提交 76e8bb53 authored 作者: chenshiying's avatar chenshiying

[新增] 廊坊生成大小类管理问题sql

上级 98683b34
......@@ -52,5 +52,11 @@
<version>5.0.10.RELEASE</version>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>8.0.21</version>
</dependency>
</dependencies>
</project>
......@@ -29,7 +29,7 @@ public class GeneratorCommandManualScript {
//TODO 1:事件,2:部件
public static final String CASE_TYPE = "2";
public static final String FILE_NAME = "部件0523.xlsx";
public static final String FILE_NAME = "井盖大小类扩展all.xlsx";
public static Map<String, String> bigTypeIdMap = new LinkedHashMap<>();
......@@ -38,7 +38,7 @@ public class GeneratorCommandManualScript {
protected static String root_path = "F:\\9Git140\\loit-build-common\\loit-build-component\\loit-build-deploy-env\\src\\main\\resources\\langfang";
public static final String CHECK_FILE_NAME = root_path + "\\4、验证.sql";
public static final String CHECK_FILE_NAME = root_path + "\\5、验证.sql";
public static void main(String[] args) {
......@@ -211,6 +211,17 @@ public class GeneratorCommandManualScript {
String jobConfig = FreeMarkerUtils.process("langfang" + "\\smallTypeScript.ftl", model);
FileUtils.append(configFilePath, jobConfig);
// String sql = "select * from geocode_component where big_type = '" + commandManualDTO.getBigTypeName() + "' and obj_type = '" + commandManualDTO.getSmallTypeName() + "';\n";
// FileUtils.append(root_path + "\\6、部件表geocode_component.sql", sql);
String sql2 = "update geocode_component set big_code = '" + commandManualDTO.getBigTypeCode() + "' , obj_type_code = '"
+ commandManualDTO.getSmallTypeCode() + "' , small_code = '" + commandManualDTO.getSmallTypeCode() + "' where big_type = '"
+ commandManualDTO.getBigTypeName() + "' and obj_type = '" + commandManualDTO.getSmallTypeName() + "';\n";
FileUtils.append(root_path + "\\6、部件表geocode_component.sql", sql2);
}
}
......@@ -257,7 +268,6 @@ public class GeneratorCommandManualScript {
model.put("cunit", climitUnit.getUnit());
String sql = "select * from digital_command_manual where manage_problem = '" + commandManualDTO.getManageProblem() + "' and big_type_id = '" + commandManualDTO.getBigTypeId() + "' and small_type = '" + commandManualDTO.getSmallTypeName() + "';\n";
FileUtils.append(CHECK_FILE_NAME, sql);
......
package com.loit.common.langfang;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.sql.*;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
public class JdbcQueryUtils {
private static Logger logger = LoggerFactory.getLogger(JdbcQueryUtils.class);
/**
* 必要配置-数据库相关配置
*/
protected String url = "jdbc:mysql://10.39.10.228:3306/digital_city_test" + "?characterEncoding=utf8";
protected String driverName = "com.mysql.cj.jdbc.Driver";
protected String user = "root";
protected String password = "Loit!#2022A";
private Connection conn = null;
public void init() {
try {
Class.forName(driverName);
conn = DriverManager.getConnection(url, user, password);
} catch (Exception e) {
logger.error(e.getMessage(), e);
}
}
public static void main(String[] args) {
try {
JdbcQueryUtils generator = new JdbcQueryUtils();
generator.init();
List<String> columnList = new ArrayList<>();
columnList.add("id");
columnList.add("obj_code");
columnList.add("obj_name");
List<Map<String, String>> result = generator.queryDictInfo("select id, obj_code, obj_name from base_base_casetype where level = 2 and case_type = 2 and obj_name = '交通设施'", columnList);
System.out.println(result.isEmpty());
} catch (Exception e) {
logger.error(e.getMessage(), e);
}
System.exit(0);
}
public List<Map<String, String>> queryDictInfo(String sql, List<String> columnList) {
List<Map<String, String>> resultList = new ArrayList();
PreparedStatement pstate = null;
try {
pstate = conn.prepareStatement(sql);
ResultSet results = pstate.executeQuery();
while (results.next()) {
Map<String, String> objInfo = new LinkedHashMap<>();
for (String col : columnList) {
objInfo.put(col, results.getString(col));
}
resultList.add(objInfo);
}
} catch (SQLException e) {
logger.error(e.getMessage(), e);
} finally {
try {
pstate.close();
} catch (SQLException ignore) {
}
}
return resultList;
}
public void close() {
try {
conn.close();
} catch (SQLException ignore) {
}
}
}
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论