Pārlūkot izejas kodu

修改机构信息后向前置库 推送数据

pull/1/head
yulin pirms 10 mēnešiem
vecāks
revīzija
53951e733b
4 mainītis faili ar 68 papildinājumiem un 32 dzēšanām
  1. +34
    -29
      mztb/src/main/java/cc/smtweb/biz/mztb/web/base/partyInfo/PartyInfoHandler.java
  2. +11
    -2
      mztb/src/main/java/cc/smtweb/biz/mztb/web/base/partyInfo/PartyInfoService.java
  3. +1
    -1
      mztb/src/main/java/cc/smtweb/biz/mztb/web/tool/DbUtil.java
  4. +22
    -0
      mztb/src/main/resources/static/event/mztb/base/partyInfo/partyInfoCard.js

+ 34
- 29
mztb/src/main/java/cc/smtweb/biz/mztb/web/base/partyInfo/PartyInfoHandler.java Parādīt failu

@@ -1,9 +1,13 @@
package cc.smtweb.biz.mztb.web.base.partyInfo;

import cc.smtweb.biz.mztb.web.base.DbSourceConfig;
import cc.smtweb.biz.mztb.web.base.PartyInfo;
import cc.smtweb.biz.mztb.web.tool.DbUtil;
import cc.smtweb.framework.core.common.R;
import cc.smtweb.framework.core.common.SwMap;
import cc.smtweb.framework.core.db.DbEngine;
import cc.smtweb.framework.core.mvc.service.AbstractHandler;
import cc.smtweb.framework.core.session.UserSession;
import cc.smtweb.framework.core.util.DateUtil;
import cc.smtweb.system.bpm.web.engine.model.common.ModelSaveHandler;
import org.slf4j.Logger;
@@ -15,37 +19,9 @@ import java.sql.SQLException;
import java.util.Map;
import java.util.StringJoiner;

public class PartyInfoHandler extends ModelSaveHandler {
public class PartyInfoHandler extends AbstractHandler {
private final static Logger logger = LoggerFactory.getLogger(PartyInfoHandler.class);
@Override
protected void doSave() {
super.doSave();
// 将修改的机构数据推送到前置库
DbEngine instance = DbEngine.getInstance();
DbSourceConfig dbSourceConfig = instance.findDao(DbSourceConfig.class).queryEntityWhere("dsc_use_state = 0");
Connection connection = null;
try {
connection = DriverManager.getConnection(dbSourceConfig.getWholeUrl(), dbSourceConfig.getUsername(), dbSourceConfig.getPassword());
}catch (SQLException sqlException) {
logger.debug("创建 Connection Exception:",sqlException);
}
DbUtil dbUtil = new DbUtil(connection);
SwMap swmap = this.bean.getData();
// 处理前置库和本系统 机构表不同的字段
swmap.put("state","0");
swmap.put("wr_time", DateUtil.nowDateTimeLong());
swmap.put("wr_aspect",1);
swmap.put("id",instance.nextId());
String sql = buildInsertSql(swmap);
logger.info("====向前置库推送数据的sql==== :{}",sql);
try {
boolean insert = dbUtil.insert(sql);
if(!insert) logger.info("推送机构信息失败!!!!");
} catch (SQLException e) {
logger.debug("修改机构信息后,向前置库推送机构信息失败:",e);
}

}
private String buildInsertSql(SwMap entity) {
entity.remove("_def_table_name");
entity.remove("pi_update_at");
@@ -73,4 +49,33 @@ public class PartyInfoHandler extends ModelSaveHandler {

return sql.toString();
}

public R pushParty(SwMap params, UserSession us) {
// 将修改的机构数据推送到前置库
DbEngine instance = DbEngine.getInstance();
DbSourceConfig dbSourceConfig = instance.findDao(DbSourceConfig.class).queryEntityWhere("dsc_use_state = 0");
Connection connection = null;
try {
connection = DriverManager.getConnection(dbSourceConfig.getWholeUrl(), dbSourceConfig.getUsername(), dbSourceConfig.getPassword());
}catch (SQLException sqlException) {
logger.debug("创建 Connection Exception:",sqlException);
}
PartyInfo partyInfo = instance.queryEntity(PartyInfo.class, us.getPartyId());
DbUtil dbUtil = new DbUtil(connection);
SwMap swmap = partyInfo.getData();
// 处理前置库和本系统 机构表不同的字段
swmap.put("state","0");
swmap.put("wr_time", DateUtil.nowDateTimeLong());
swmap.put("wr_aspect",1);
swmap.put("id",instance.nextId());
String sql = buildInsertSql(swmap);
logger.info("====向前置库推送数据的sql==== :{}",sql);
try {
boolean insert = dbUtil.insert(sql);
if(!insert) logger.info("推送机构信息失败!!!!");
} catch (SQLException e) {
logger.debug("修改机构信息后,向前置库推送机构信息失败:",e);
}
return R.success();
}
}

+ 11
- 2
mztb/src/main/java/cc/smtweb/biz/mztb/web/base/partyInfo/PartyInfoService.java Parādīt failu

@@ -1,7 +1,12 @@
package cc.smtweb.biz.mztb.web.base.partyInfo;

import cc.smtweb.biz.mztb.web.base.partyDataFill.PartyDataCustomHandler;
import cc.smtweb.framework.core.annotation.SwBody;
import cc.smtweb.framework.core.annotation.SwService;
import cc.smtweb.framework.core.common.R;
import cc.smtweb.framework.core.common.SwMap;
import cc.smtweb.framework.core.mvc.service.AbstractHandler;
import cc.smtweb.framework.core.session.UserSession;
import cc.smtweb.system.bpm.web.engine.model.listcard.normal.LCNormalService;

/**
@@ -10,11 +15,12 @@ import cc.smtweb.system.bpm.web.engine.model.listcard.normal.LCNormalService;
*/
@SwService
public class PartyInfoService extends LCNormalService {
//public final static String TYPE_DEMO = "demo";
public final static String TYPE_CUSTOM = "custom";
@Override
protected AbstractHandler createHandler(String type) {
switch (type) {
case TYPE_MODEL_SAVE:return new PartyInfoHandler();
case TYPE_CUSTOM:
return new PartyInfoHandler();
}
return super.createHandler(type);
}
@@ -25,5 +31,8 @@ public class PartyInfoService extends LCNormalService {
return pageHandler(params, us, TYPE_DEMO, handler -> ((DemoHandler)handler).demo());
}
*/
public R pushParty(@SwBody SwMap params, UserSession us) {
return pageHandler(params, us, TYPE_CUSTOM, handler -> ((PartyInfoHandler)handler).pushParty(params,us));
}

}

+ 1
- 1
mztb/src/main/java/cc/smtweb/biz/mztb/web/tool/DbUtil.java Parādīt failu

@@ -60,7 +60,7 @@ public class DbUtil {
public boolean insert(String sql) throws SQLException {
Statement statement = getStatement();
boolean execute = statement.execute(sql);
statement.close();
connection.close();
return execute;
}



+ 22
- 0
mztb/src/main/resources/static/event/mztb/base/partyInfo/partyInfoCard.js Parādīt failu

@@ -0,0 +1,22 @@
/**
* Created by 1 at 2024-01-09 17:49:53
* 注册事件类【机构信息编辑】,参看event.defaultEvent.js
*/
window.$swEvent.setup("mztb.base.partyInfo.partyInfoCard", {
setup(page){
const { $params, $refs, $widgets, $model, $utils, $tabRouter, $api, $lifecycle, $engine, $parent } = page || {};
const { $$message, $$http, $$sys, $$UtilPub } = $utils || {};

// 示例
const demoFunc = () => {

};

const pushPartyInfo = () => {
const rt = $$http.post("mztb/partyInfo/pushParty", {id: $model.card.data.form.pi_id})
}
return {
demoFunc,pushPartyInfo
}
}
});

Notiek ielāde…
Atcelt
Saglabāt