@@ -88,25 +100,25 @@
@@ -254,30 +266,37 @@
return false;
});
- $('#areaName').on('click', function() {
- top.dialog.open({
- title: '选择地区',
- url: top.restAjax.path('route/area/get-select?areaName={areaName}', [encodeURI($('#areaName').val())]),
- width: '600px',
- height: '225px',
- onClose: function() {
- var selectedAreaArray = top.dialog.dialogData.selectedAreaArray;
- if(selectedAreaArray.length > 0) {
- var areaCode = '';
- var areaName = '';
- areaCode = selectedAreaArray[selectedAreaArray.length - 1].areaCode;
- for(var i = 0, item; item = selectedAreaArray[i++];) {
- if(areaName) {
- areaName += ' / ';
+ // 区域选择
+ (function() {
+ $('#areaSelectBtn').on('click', function() {
+ top.dialog.open({
+ title: '选择地区',
+ url: top.restAjax.path('route/area/get-select?areaName={areaName}', [encodeURI($('#departmentAreaName').val())]),
+ width: '600px',
+ height: '225px',
+ onClose: function() {
+ var selectedAreaArray = top.dialog.dialogData.selectedAreaArray;
+ if(selectedAreaArray.length > 0) {
+ var areaCode = '';
+ var areaName = '';
+ areaCode = selectedAreaArray[selectedAreaArray.length - 1].areaCode;
+ for(var i = 0, item; item = selectedAreaArray[i++];) {
+ if(areaName) {
+ areaName += ' / ';
+ }
+ areaName += item.areaName;
}
- areaName += item.areaName;
+ $('#areaCode').val(areaCode);
+ $('#areaName').val(areaName);
}
- $('#areaCode').val(areaCode);
- $('#areaName').val(areaName);
}
- }
+ })
+ });
+ $('#areaCleanBtn').on('click', function () {
+ $('#areaCode').val('');
+ $('#areaName').val('');
})
- })
+ })();
$('.close').on('click', function() {
closeBox();
diff --git a/src/test/java/cn/com/tenlion/usercenter/DepartmentTest.java b/src/test/java/cn/com/tenlion/usercenter/DepartmentTest.java
new file mode 100644
index 0000000..22e19e3
--- /dev/null
+++ b/src/test/java/cn/com/tenlion/usercenter/DepartmentTest.java
@@ -0,0 +1,202 @@
+package cn.com.tenlion.usercenter;
+
+import ink.wgink.util.UUIDUtil;
+import ink.wgink.util.date.DateUtil;
+import ink.wgink.util.jdbc.JdbcUtil;
+import org.apache.commons.lang3.StringUtils;
+import org.junit.Test;
+
+import java.sql.*;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * @Description: 部门数据
+ * @Author: WenG
+ * @Date: 2022/3/5 10:04
+ * @Version: 1.0
+ **/
+public class DepartmentTest {
+
+ public static String[] WLCB = new String[]{"发改委民委", "工信局", "卫生健康委员会", "审计局", "财政局", "住建委", "交通局", "自然资源局", "农牧局", "水利局", "林业和草原局", "公安局", "司法局", "人社局", "民政局", "教育局", "科技局", "文化旅游体育局", "商务局", "金融办", "税务局", "统计局", "生态环境局", "市场监督管理局", "乡村振兴局", "气象局信访局", "邮政管理局", "应急管理局", "供销社", "人民银行", "国资委", "退役军人事务局", "区域经济合作局", "医疗保障局", "政务服务局"};
+ public static String[] QXQ = new String[]{"人民政府办公室", "发展和改革委员会", "教育局", "工业和信息化局", "民族事务委员会", "民政局", "司法局", "财政局", "人力资源和社会保障局", "住房和城乡建设局", "农牧水利局(乡村振兴局)", "商务局", "文化旅游体育局", "卫生健康委员会", "退役军人事务局", "应急管理局", "审计局", "国有资产监督管理委员会", "市场监督管理局", "统计局", "医疗保障局", "信访局", "城市管理综合执法局", "科技和大数据管理局", "政务服务局"};
+ public static String[] JD = new String[]{"派出所", "司法所", "物业所", "城管中队", "市场管理中队"};
+ public static String[] SQ = new String[]{"居委会", "支委会"};
+
+ // 区域
+ private String SQL_GET_AREA_BY_AREA_CODE = "SELECT area_id, area_parent_id, area_name, area_code FROM data_area WHERE area_code = ?";
+ private String SQL_GET_AREA_BY_AREA_ID = "SELECT area_id, area_parent_id, area_name, area_code FROM data_area WHERE area_id = ?";
+ private String SQL_LIST_AREA_BY_PARENT_ID = "SELECT area_id, area_parent_id, area_name, area_code, area_level FROM data_area WHERE area_parent_id = ?";
+ /**
+ * 部门
+ */
+ private String SQL_COUNT_DEPARTMENT_BY_PARENT_ID = "SELECT COUNT(*) count FROM sys_department WHERE department_parent_id = ?";
+ private String SQL_SAVE_DEPARTMENT = "INSERT INTO sys_department(`department_id`,`department_parent_id`,`department_name`,`department_code`,`department_type`,`department_state`, `department_order`,`department_area_code`,`department_area_name`) VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?)";
+ private static int COUNT_SAVED_AREA_DEPARTMENT = 0;
+ private static int COUNT_SAVED_DEPARTMENT = 0;
+
+ @Test
+ public void importData() throws SQLException {
+ long startTime = System.currentTimeMillis();
+ String currentDateTime = DateUtil.getTime();
+ Connection connection = DriverManager.getConnection(String.format("jdbc:mysql://%s:%s/db_smart_city_usercenter?useUnicode=true&characterEncoding=utf8&characterSetResults=utf8&autoReconnect=true&failOverReadOnly=false&useSSL=false&serverTimezone=UTC&nullCatalogMeansCurrent=true", "192.168.0.103", 3306), "root", "root");
+
+ // 区域
+ PreparedStatement getAreaByCodePS = connection.prepareStatement(SQL_GET_AREA_BY_AREA_CODE);
+ PreparedStatement getAreaByIdPS = connection.prepareStatement(SQL_GET_AREA_BY_AREA_ID);
+ PreparedStatement listAreaByParentIdPS = connection.prepareStatement(SQL_LIST_AREA_BY_PARENT_ID);
+
+ // 部门
+ PreparedStatement countDepartmentPS = connection.prepareStatement(SQL_COUNT_DEPARTMENT_BY_PARENT_ID);
+ PreparedStatement saveDepartmentPS = connection.prepareStatement(SQL_SAVE_DEPARTMENT);
+
+ saveAreaDepartment("0", "", "0", listAreaByParentIdPS, countDepartmentPS, saveDepartmentPS, getAreaByCodePS, getAreaByIdPS);
+
+ long endTime = System.currentTimeMillis();
+ System.out.println("耗时:" + (endTime - startTime) + "ms");
+ System.out.println("****************************************");
+ System.out.println("区域: " + COUNT_SAVED_AREA_DEPARTMENT);
+ System.out.println("部门: " + COUNT_SAVED_DEPARTMENT);
+ System.out.println("****************************************");
+ }
+
+ private void saveAreaDepartment(String departmentParentId, String departmentParentCode, String areaParentId, PreparedStatement listAreaByParentIdPS, PreparedStatement countDepartmentPS, PreparedStatement saveDepartmentPS, PreparedStatement getAreaByCodePS, PreparedStatement getAreaByParentIdPS) throws SQLException {
+ // 查询子区域
+ listAreaByParentIdPS.setString(1, areaParentId);
+ ResultSet resultSet = listAreaByParentIdPS.executeQuery();
+ List