diff --git a/pom.xml b/pom.xml index fb39c0e4..13b10b90 100644 --- a/pom.xml +++ b/pom.xml @@ -211,7 +211,12 @@ jsoup 1.17.2 - + + + com.alibaba + druid + 1.2.23 + org.apache.httpcomponents diff --git a/src/main/java/Tools/AddZhengZhou103GongWenNum.java b/src/main/java/Tools/AddZhengZhou103GongWenNum.java index 70cb3138..4cd7c93d 100644 --- a/src/main/java/Tools/AddZhengZhou103GongWenNum.java +++ b/src/main/java/Tools/AddZhengZhou103GongWenNum.java @@ -3,28 +3,67 @@ package Tools; import cn.hutool.core.io.FileUtil; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; +import com.jfinal.kit.Kv; +import com.jfinal.kit.PropKit; +import com.jfinal.plugin.activerecord.ActiveRecordPlugin; +import com.jfinal.plugin.activerecord.Db; +import com.jfinal.plugin.activerecord.Record; +import com.jfinal.plugin.activerecord.dialect.MysqlDialect; +import com.jfinal.plugin.druid.DruidPlugin; + +import java.io.File; +import java.sql.*; +import java.time.LocalDateTime; +import java.time.format.DateTimeFormatter; public class AddZhengZhou103GongWenNum { + //下面的工作流定义没有用到,但是结合工作界面才能读懂是什么意思 + //select * from t_intellioa_flow_define where flow_name='0105改-收文登记流程'; -- flow_id = 68 工作流id + + public static String dirPath = "D:\\ZhengZhou103"; + /** - * 添加文号 + * 备份文件 + * + * @param tableName + * @param content + */ + public static void BackupData(String tableName, String content) { + File directory = new File(dirPath); + if (!directory.exists() && directory.isDirectory()) { + //创建目录 + directory.mkdirs(); + } + //备份的文件名称: 当前时间的年月日时分秒 + String path = tableName + "_" + LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyyMMddHHmmss")) + ".json"; + FileUtil.writeUtf8String(content, path); + } + + /** + * 添加Form * * @param wenHao 文号 - * @param j1 * @return */ - public static JSONObject addWenHao(String wenHao, JSONObject j1) { - for (Object fieldList : j1.getJSONArray("field_list")) { + public static Kv addForm(String wenHao) { + int form_id = 36; + //1、修改form下的json数据 + String sql = "select form_id,form_json from t_intellioa_flow_form where form_id=?"; + String form_json = Db.findFirst(sql, form_id).getStr("form_json"); + //备份 + BackupData("t_intellioa_flow_form", form_json); + JSONObject jo = JSONObject.parseObject(form_json); + int id = 0; + for (Object fieldList : jo.getJSONArray("field_list")) { JSONObject j2 = (JSONObject) fieldList; for (Object com : j2.getJSONArray("com")) { JSONObject j3 = (JSONObject) com; if (j3.getString("field_title").equals("文件编号")) { JSONArray ja = j3.getJSONArray("textAry"); - int id = 0; for (Object o : ja) { JSONObject j4 = (JSONObject) o; id = Integer.parseInt(j4.getString("id")); - String name = j4.getString("name"); } JSONObject j5 = new JSONObject(); j5.put("id", ++id); @@ -33,52 +72,67 @@ public class AddZhengZhou103GongWenNum { } } } - return j1; + Kv kv = Kv.create(); + kv.set("id", id); + kv.set("data", jo); + kv.set("form_id", form_id); + //更新到数据库 + sql = "update t_intellioa_flow_form set form_json=? where form_id=?"; + Db.update(sql, jo.toJSONString(), form_id); + return kv; } /** - * 打印输出文号 + * 添加form_field表 * - * @param j1 + * @param id + * @param wenHao */ - public static void printWenHao(JSONObject j1) { - for (Object fieldList : j1.getJSONArray("field_list")) { - JSONObject j2 = (JSONObject) fieldList; - for (Object com : j2.getJSONArray("com")) { - JSONObject j3 = (JSONObject) com; - if (j3.getString("field_title").equals("文件编号")) { - JSONArray ja = j3.getJSONArray("textAry"); - int id = 0; - for (Object o : ja) { - JSONObject j4 = (JSONObject) o; - id = Integer.parseInt(j4.getString("id")); - String name = j4.getString("name"); - System.out.println("id=" + id + " name=" + name); - } - } - } - } + public static Kv addField(int id, String wenHao) { + String sql = "select field_id,field_attribute from t_intellioa_flow_form_field where form_id=36 and field_label='原文号' and is_deleted=0;"; + Record record = Db.findFirst(sql); + String field_attribute = record.getStr("field_attribute"); + //备份 + BackupData("t_intellioa_flow_form_field", field_attribute); + int field_id = record.getInt("field_id"); + JSONObject jo = JSONObject.parseObject(field_attribute); + JSONArray ja = jo.getJSONArray("textAry"); + JSONObject jAdd = new JSONObject(); + jAdd.put("id", id); + jAdd.put("name", wenHao); + ja.add(jAdd); + Kv kv = Kv.create(); + kv.set("field_id", field_id); + kv.set("data", jo); + //更新到数据库 + sql = "update t_intellioa_flow_form_field set field_attribute=? where field_id=?"; + Db.update(sql, jo.toJSONString(), field_id); + return kv; } - public static void main(String[] args) { - //文号 - String wenHao = "郑动联"; - /* - select * from t_intellioa_flow_define where flow_name='0105改-收文登记流程'; -- flow_id = 68 工作流id - select form_json from t_intellioa_flow_form where form_id=36; -- 表单 - select * from t_intellioa_flow_form_field where form_id=36; + public static void main(String[] args) throws SQLException { + //加载配置文件 + String configFile = "application_ZhengZhou103.properties"; + PropKit.use(configFile); + + // 数据库配置 + DruidPlugin druidPlugin = new DruidPlugin(PropKit.get("jdbcUrl"), PropKit.get("user"), + PropKit.get("password").trim(), PropKit.get("driverClassName")); + druidPlugin.start(); + + ActiveRecordPlugin arp = new ActiveRecordPlugin(druidPlugin); + arp.setDialect(new MysqlDialect()); + arp.start(); + + //想要添加的文号 + String wenHao = "郑动联"; - select * from t_intellioa_flow_form_field where form_id=36 and field_label='原文号' and is_deleted=0; - */ - String content = FileUtil.readUtf8String("D:\\dsWork\\QingLong\\src\\main\\java\\Tools\\form_json.json"); - //添加文号 - JSONObject j1 = JSONObject.parseObject(content); - j1 = addWenHao(wenHao, j1); - //显示添加后的结果 - System.out.println(j1); + //1、form下的json数据 + Kv kv = addForm(wenHao); + int id = kv.getInt("id"); - //只输出文号 - printWenHao(j1); + //2、form_field下的json数据 + addField(id, wenHao); } } diff --git a/src/main/java/Tools/field_attribute.json b/src/main/java/Tools/field_attribute.json deleted file mode 100644 index 537730ae..00000000 --- a/src/main/java/Tools/field_attribute.json +++ /dev/null @@ -1,259 +0,0 @@ -{ - "colId": 2, - "rowId": 1, - "field_title": "文件编号", - "controlIndex": "111", - "field_type": 7, - "defaultName": "文件编号", - "defaultType": 2, - "isInput": true, - "focusType": "12", - "textAry": [ - { - "id": 0, - "name": "郑教师函" - }, - { - "id": 1, - "name": "郑教师" - }, - { - "id": 2, - "name": "郑教基函" - }, - { - "id": 3, - "name": "郑教基" - }, - { - "id": 4, - "name": "郑教体卫艺函" - }, - { - "id": 5, - "name": "郑教招函" - }, - { - "id": 6, - "name": "郑教监管函" - }, - { - "id": 7, - "name": "郑教工委办" - }, - { - "id": 8, - "name": "郑教计法函" - }, - { - "id": 9, - "name": "郑教财函" - }, - { - "id": 10, - "name": "郑教科信函" - }, - { - "id": 11, - "name": "郑教任" - }, - { - "id": 12, - "name": "郑教安函" - }, - { - "id": 13, - "name": "郑教安" - }, - { - "id": 14, - "name": "郑教信函" - }, - { - "id": 15, - "name": "郑教宣外函" - }, - { - "id": 16, - "name": "郑教督函" - }, - { - "id": 17, - "name": "郑教组函" - }, - { - "id": 18, - "name": "郑教组秘函" - }, - { - "id": 19, - "name": "郑教人函" - }, - { - "id": 20, - "name": "郑教职成函" - }, - { - "id": 21, - "name": "郑教离退函" - }, - { - "id": 22, - "name": "郑教办函" - }, - { - "id": 23, - "name": "郑教办" - }, - { - "id": 24, - "name": "郑教关字" - }, - { - "id": 25, - "name": "郑教关" - }, - { - "id": 26, - "name": "郑教党建函" - }, - { - "id": 27, - "name": "郑教党风函" - }, - { - "id": 28, - "name": "郑教党" - }, - { - "id": 29, - "name": "郑教疫防办" - }, - { - "id": 30, - "name": "郑政教督办" - }, - { - "id": 31, - "name": "郑红" - }, - { - "id": 32, - "name": "郑疫防教专班" - }, - { - "id": 33, - "name": "郑校外培训治理办" - }, - { - "id": 34, - "name": "党政联席会议纪要" - }, - { - "id": 35, - "name": "教体卫艺函" - }, - { - "id": 36, - "name": "教基函" - }, - { - "id": 37, - "name": "教监管函" - }, - { - "id": 38, - "name": "局长办公会议纪要" - }, - { - "id": 39, - "name": "驻郑教纪" - }, - { - "id": 40, - "name": "教育工作通报" - }, - { - "id": 41, - "name": "会议纪要" - }, - { - "id": 42, - "name": "教财函" - }, - { - "id": 43, - "name": "教育工作通报" - }, - { - "id": 44, - "name": "教党风函" - }, - { - "id": 45, - "name": "无章公文" - }, - { - "id": 46, - "name": "通知" - }, - { - "id": 47, - "name": "郑教资保函" - }, - { - "id": 48, - "name": "郑教信息函" - }, - { - "id": 49, - "name": "郑民文" - }, - { - "id": 50, - "name": "郑消" - }, - { - "id": 51, - "name": "郑教计法" - }, - { - "id": 52, - "name": "郑教体卫艺" - }, - { - "id": 53, - "name": "郑教党风" - }, - { - "id": 54, - "name": "郑教食安办" - }, - { - "id": 55, - "name": "郑教组秘" - }, - { - "id": 56, - "name": "郑教教评函" - }, - { - "id": 57, - "name": "豫教财" - }, - { - "id": 58, - "name": "郑数字办" - }, - { - "id": 59, - "name": "郑安防委办" - }, - { - "id": 60, - "name": "郑教工委" - } - ], - "field_unique_id": "111", - "field_label": "原文号" -} \ No newline at end of file diff --git a/src/main/java/Tools/form_json.json b/src/main/java/Tools/form_json.json deleted file mode 100644 index 284e180c..00000000 --- a/src/main/java/Tools/form_json.json +++ /dev/null @@ -1,755 +0,0 @@ -{ - "table_list": [ - { - "id": 0, - "ttd": [ - { - "id": 0, - "colSpan": 6, - "rowType": 0, - "classData": "", - "textPosition": "center" - } - ], - "isMerge": true - }, - { - "id": 1, - "ttd": [ - { - "id": 1, - "colSpan": 1, - "rowType": 1, - "classData": "", - "textPosition": "left" - }, - { - "id": 2, - "colSpan": 2, - "rowType": 1, - "classData": "", - "textPosition": "left" - }, - { - "id": 3, - "colSpan": 1, - "rowType": 1, - "classData": "", - "textPosition": "left" - }, - { - "id": 4, - "colSpan": 2, - "rowType": 1, - "classData": "", - "textPosition": "left" - } - ], - "isMerge": true - }, - { - "id": 2, - "ttd": [ - { - "id": 5, - "colSpan": 1, - "rowType": 2, - "classData": "", - "textPosition": "left" - }, - { - "id": 6, - "colSpan": 2, - "rowType": 2, - "classData": "", - "textPosition": "left" - }, - { - "id": 7, - "colSpan": 1, - "rowType": 2, - "classData": "", - "textPosition": "left" - }, - { - "id": 8, - "colSpan": 2, - "rowType": 2, - "classData": "", - "textPosition": "left" - } - ], - "isMerge": true - }, - { - "id": 3, - "ttd": [ - { - "id": 9, - "colSpan": 1, - "rowType": 3, - "classData": "", - "textPosition": "left" - }, - { - "id": 10, - "colSpan": 2, - "rowType": 3, - "classData": "", - "textPosition": "left" - }, - { - "id": 11, - "colSpan": 1, - "rowType": 3, - "classData": "", - "textPosition": "left" - }, - { - "id": 12, - "colSpan": 2, - "rowType": 3, - "classData": "", - "textPosition": "left" - } - ], - "isMerge": true - }, - { - "id": 4, - "ttd": [ - { - "id": 13, - "colSpan": 1, - "rowType": 4, - "classData": "", - "textPosition": "left" - }, - { - "id": 14, - "colSpan": 5, - "rowType": 4, - "classData": "", - "textPosition": "left" - } - ], - "isMerge": true - }, - { - "id": 5, - "ttd": [ - { - "id": 15, - "colSpan": 1, - "rowType": 5, - "classData": "", - "textPosition": "left" - }, - { - "id": 16, - "colSpan": 5, - "rowType": 5, - "classData": "", - "textPosition": "left" - } - ], - "isMerge": true - } - ], - "field_list": [ - { - "id": 0, - "com": [ - - ], - "type": 0, - "className": "" - }, - { - "id": 1, - "com": [ - { - "field_title": "标题", - "field_type": 6, - "focusType": "00", - "colId": 0, - "rowId": 0, - "isInput": true, - "field_label": "标题", - "field_unique_id": "10", - "color": 1, - "defaultName": "请输入标题", - "controlIndex": "10" - }, - { - "field_title": "文本", - "field_type": 9, - "focusType": "01", - "colId": 1, - "rowId": 0, - "isInput": false, - "field_label": "文本_11", - "field_unique_id": "11", - "color": 1, - "defaultName": "收文日期", - "thick": 1, - "fontSize": 16, - "controlIndex": "11" - }, - { - "field_title": "文本", - "field_type": 9, - "focusType": "02", - "colId": 2, - "rowId": 0, - "isInput": false, - "field_label": "文本_12", - "field_unique_id": "12", - "color": 1, - "defaultName": "原文号", - "thick": 1, - "fontSize": 16, - "controlIndex": "12" - }, - { - "field_title": "文本", - "field_type": 9, - "focusType": "03", - "colId": 3, - "rowId": 0, - "isInput": false, - "field_label": "文本_13", - "field_unique_id": "13", - "color": 1, - "defaultName": "紧急程度", - "thick": 1, - "fontSize": 16, - "controlIndex": "13" - }, - { - "field_title": "文本", - "field_type": 9, - "focusType": "04", - "colId": 4, - "rowId": 0, - "isInput": false, - "field_label": "文本_14", - "field_unique_id": "14", - "color": 1, - "defaultName": "简介", - "thick": 1, - "fontSize": 16, - "controlIndex": "14" - }, - { - "field_title": "文本", - "field_type": 9, - "focusType": "05", - "colId": 5, - "rowId": 0, - "isInput": false, - "field_label": "文本_15", - "field_unique_id": "15", - "color": 1, - "defaultName": "附件", - "thick": 1, - "fontSize": 16, - "controlIndex": "15" - }, - { - "field_title": "文本", - "field_type": 9, - "focusType": "21", - "colId": 1, - "rowId": 2, - "isInput": false, - "field_label": "文本_16", - "field_unique_id": "16", - "color": 1, - "defaultName": "来文机关", - "thick": 1, - "fontSize": 16, - "controlIndex": "16" - }, - { - "field_title": "文本", - "field_type": 9, - "focusType": "22", - "colId": 2, - "rowId": 2, - "isInput": false, - "field_label": "文本_17", - "field_unique_id": "17", - "color": 1, - "defaultName": "密级", - "thick": 1, - "fontSize": 16, - "controlIndex": "17" - }, - { - "field_title": "文本", - "field_type": 9, - "focusType": "23", - "colId": 3, - "rowId": 2, - "isInput": false, - "field_label": "文本_18", - "field_unique_id": "18", - "color": 1, - "defaultName": "文件分类", - "thick": 1, - "fontSize": 16, - "controlIndex": "18" - }, - { - "field_title": "日期", - "field_type": 4, - "focusType": "11", - "colId": 1, - "rowId": 1, - "isInput": true, - "field_label": "收文日期", - "field_unique_id": "19", - "dateType": 1, - "defaultType": 2, - "controlIndex": "19" - }, - { - "field_title": "单行输入框", - "field_type": 0, - "focusType": "31", - "colId": 1, - "rowId": 3, - "isInput": true, - "field_label": "来文机关", - "field_unique_id": "110", - "defaultName": "请输入", - "controlIndex": "110" - }, - { - "field_title": "文件编号", - "field_type": 7, - "focusType": "12", - "colId": 2, - "rowId": 1, - "isInput": true, - "field_label": "原文号", - "field_unique_id": "111", - "textAry": [ - { - "name": "郑教师函", - "id": 0 - }, - { - "name": "郑教师", - "id": 1 - }, - { - "name": "郑教基函", - "id": 2 - }, - { - "name": "郑教基", - "id": 3 - }, - { - "name": "郑教体卫艺函", - "id": 4 - }, - { - "name": "郑教招函", - "id": 5 - }, - { - "name": "郑教监管函", - "id": 6 - }, - { - "name": "郑教工委办", - "id": 7 - }, - { - "name": "郑教计法函", - "id": 8 - }, - { - "name": "郑教财函", - "id": 9 - }, - { - "name": "郑教科信函", - "id": 10 - }, - { - "name": "郑教任", - "id": 11 - }, - { - "name": "郑教安函", - "id": 12 - }, - { - "name": "郑教安", - "id": 13 - }, - { - "name": "郑教信函", - "id": 14 - }, - { - "name": "郑教宣外函", - "id": 15 - }, - { - "name": "郑教督函", - "id": 16 - }, - { - "name": "郑教组函", - "id": 17 - }, - { - "name": "郑教组秘函", - "id": 18 - }, - { - "name": "郑教人函", - "id": 19 - }, - { - "name": "郑教职成函", - "id": 20 - }, - { - "name": "郑教离退函", - "id": 21 - }, - { - "name": "郑教办函", - "id": 22 - }, - { - "name": "郑教办", - "id": 23 - }, - { - "name": "郑教关字", - "id": 24 - }, - { - "name": "郑教关", - "id": 25 - }, - { - "name": "郑教党建函", - "id": 26 - }, - { - "name": "郑教党风函", - "id": 27 - }, - { - "name": "郑教党", - "id": 28 - }, - { - "name": "郑教疫防办", - "id": 29 - }, - { - "name": "郑政教督办", - "id": 30 - }, - { - "name": "郑红", - "id": 31 - }, - { - "name": "郑疫防教专班", - "id": 32 - }, - { - "name": "郑校外培训治理办", - "id": 33 - }, - { - "name": "党政联席会议纪要", - "id": 34 - }, - { - "name": "教体卫艺函", - "id": 35 - }, - { - "name": "教基函", - "id": 36 - }, - { - "name": "教监管函", - "id": 37 - }, - { - "name": "局长办公会议纪要", - "id": 38 - }, - { - "name": "驻郑教纪", - "id": 39 - }, - { - "name": "教育工作通报", - "id": 40 - }, - { - "name": "会议纪要", - "id": 41 - }, - { - "name": "教财函", - "id": 42 - }, - { - "name": "教育工作通报", - "id": 43 - }, - { - "name": "教党风函", - "id": 44 - }, - { - "name": "无章公文", - "id": 45 - }, - { - "name": "通知", - "id": 46 - }, - { - "id": 47, - "name": "郑教资保函" - }, - { - "id": 48, - "name": "郑教信息函" - }, - { - "id": 49, - "name": "郑民文" - }, - { - "id": 50, - "name": "郑消" - }, - { - "id": 51, - "name": "郑教计法" - }, - { - "id": 52, - "name": "郑教体卫艺" - }, - { - "id": 53, - "name": "郑教党风" - }, - { - "id": 54, - "name": "郑教食安办" - }, - { - "id": 55, - "name": "郑教组秘" - }, - { - "id": 56, - "name": "郑教教评函" - }, - { - "id": 57, - "name": "豫教财" - }, - { - "id": 58, - "name": "郑数字办" - }, - { - "id": 59, - "name": "郑安防委办" - }, - { - "id": 60, - "name": "郑教工委" - } - ], - "defaultName": "文件编号", - "defaultType": 2, - "controlIndex": "111" - }, - { - "field_title": "单选框", - "field_type": 2, - "focusType": "32", - "colId": 2, - "rowId": 3, - "isInput": false, - "field_label": "密级", - "field_unique_id": "112", - "radioAry": [ - { - "name": "普通", - "id": 0, - "isCheck": false - }, - { - "name": "秘密", - "id": 1, - "isCheck": false - }, - { - "name": "机密", - "id": 2, - "isCheck": false - }, - { - "name": "绝密", - "id": 3, - "isCheck": false - } - ], - "defaultType": 2, - "controlIndex": "112" - }, - { - "field_title": "紧急程度", - "field_type": 12, - "focusType": "13", - "colId": 3, - "rowId": 1, - "isInput": true, - "field_label": "紧急程度", - "field_unique_id": "113", - "radioAry": [ - { - "name": "普通", - "id": 0, - "isCheck": false - }, - { - "name": "重要", - "id": 1, - "isCheck": false - }, - { - "name": "非常重要", - "id": 2, - "isCheck": false - } - ], - "controlIndex": "113" - }, - { - "field_title": "多行输入框", - "field_type": 1, - "focusType": "14", - "colId": 4, - "rowId": 1, - "isInput": false, - "field_label": "简介", - "field_unique_id": "115", - "defaultName": "请输入", - "controlIndex": "114" - }, - { - "field_title": "附件", - "field_type": 5, - "focusType": "15", - "colId": 5, - "rowId": 1, - "isInput": false, - "field_label": "简介", - "field_unique_id": "116", - "fieldType": 1, - "controlIndex": "115" - }, - { - "field_title": "公文类别", - "field_type": 16, - "focusType": "33", - "colId": 3, - "rowId": 3, - "isInput": true, - "field_label": "文件分类", - "field_unique_id": "117", - "radioAry": [ - { - "name": "党务党建", - "id": 0, - "isCheck": false - }, - { - "name": "行政办公", - "id": 1, - "isCheck": false - }, - { - "name": "会议通知", - "id": 2, - "isCheck": false - }, - { - "name": "会纪简报", - "id": 3, - "isCheck": false - }, - { - "name": "教育教学", - "id": 4, - "isCheck": false - }, - { - "name": "校园安全", - "id": 5, - "isCheck": false - }, - { - "name": "健康卫生", - "id": 6, - "isCheck": false - }, - { - "name": "人事任免", - "id": 7, - "isCheck": false - }, - { - "name": "评先表彰", - "id": 8, - "isCheck": false - }, - { - "name": "教研培训", - "id": 9, - "isCheck": false - }, - { - "name": "科技信息", - "id": 10, - "isCheck": false - }, - { - "name": "信访老干部", - "id": 11, - "isCheck": false - } - ], - "defaultType": 2, - "controlIndex": "116" - } - ], - "type": 1 - } - ], - "tableCol": "6", - "tableColor": 1, - "sortIndex": 2 -} \ No newline at end of file diff --git a/src/main/resources/application_ZhengZhou103.properties b/src/main/resources/application_ZhengZhou103.properties new file mode 100644 index 00000000..d9bf51d6 --- /dev/null +++ b/src/main/resources/application_ZhengZhou103.properties @@ -0,0 +1,5 @@ +# 数据库信息 +driverClassName=com.mysql.cj.jdbc.Driver +user=root +password=Password123@mysql +jdbcUrl=jdbc:mysql://10.10.14.203:3306/dsideal_db?rewriteBatchedStatements=true&useUnicode=true&zeroDateTimeBehavior=CONVERT_TO_NULL&useSSL=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&autoReconnect=true&failOverReadOnly=false