You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
117 lines
4.1 KiB
117 lines
4.1 KiB
7 months ago
|
package Tools.ZhengZhou103;
|
||
7 months ago
|
|
||
|
import cn.hutool.core.io.FileUtil;
|
||
|
import com.alibaba.fastjson.JSONArray;
|
||
|
import com.alibaba.fastjson.JSONObject;
|
||
7 months ago
|
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;
|
||
7 months ago
|
|
||
7 months ago
|
public class AddWenNum {
|
||
7 months ago
|
|
||
7 months ago
|
//下面的工作流定义没有用到,但是结合工作界面才能读懂是什么意思
|
||
|
//select * from t_intellioa_flow_define where flow_name='0105改-收文登记流程'; -- flow_id = 68 工作流id
|
||
|
|
||
|
|
||
|
/**
|
||
|
* 添加Form
|
||
7 months ago
|
*
|
||
|
* @param wenHao 文号
|
||
|
* @return
|
||
|
*/
|
||
7 months ago
|
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");
|
||
|
JSONObject jo = JSONObject.parseObject(form_json);
|
||
|
int id = 0;
|
||
|
for (Object fieldList : jo.getJSONArray("field_list")) {
|
||
7 months ago
|
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");
|
||
|
for (Object o : ja) {
|
||
|
JSONObject j4 = (JSONObject) o;
|
||
|
id = Integer.parseInt(j4.getString("id"));
|
||
|
}
|
||
|
JSONObject j5 = new JSONObject();
|
||
|
j5.put("id", ++id);
|
||
|
j5.put("name", wenHao);
|
||
|
ja.add(j5);
|
||
|
}
|
||
|
}
|
||
|
}
|
||
7 months ago
|
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;
|
||
7 months ago
|
}
|
||
|
|
||
|
/**
|
||
7 months ago
|
* 添加form_field表
|
||
7 months ago
|
*
|
||
7 months ago
|
* @param id
|
||
|
* @param wenHao
|
||
7 months ago
|
*/
|
||
7 months ago
|
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");
|
||
|
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;
|
||
7 months ago
|
}
|
||
|
|
||
7 months ago
|
|
||
7 months ago
|
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 = "郑动联";
|
||
7 months ago
|
|
||
7 months ago
|
//1、form下的json数据
|
||
|
Kv kv = addForm(wenHao);
|
||
|
int id = kv.getInt("id");
|
||
7 months ago
|
|
||
7 months ago
|
//2、form_field下的json数据
|
||
|
addField(id, wenHao);
|
||
7 months ago
|
}
|
||
|
}
|