From 53951e733b56c436c8ffba57e0126a1f4c86f694 Mon Sep 17 00:00:00 2001 From: yulin <240160934@qq.com> Date: Tue, 9 Jan 2024 17:55:08 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=9C=BA=E6=9E=84=E4=BF=A1?= =?UTF-8?q?=E6=81=AF=E5=90=8E=E5=90=91=E5=89=8D=E7=BD=AE=E5=BA=93=20?= =?UTF-8?q?=E6=8E=A8=E9=80=81=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mztb/web/base/partyInfo/PartyInfoHandler.java | 63 ++++++++++++---------- .../mztb/web/base/partyInfo/PartyInfoService.java | 13 ++++- .../java/cc/smtweb/biz/mztb/web/tool/DbUtil.java | 2 +- .../event/mztb/base/partyInfo/partyInfoCard.js | 22 ++++++++ 4 files changed, 68 insertions(+), 32 deletions(-) create mode 100644 mztb/src/main/resources/static/event/mztb/base/partyInfo/partyInfoCard.js diff --git a/mztb/src/main/java/cc/smtweb/biz/mztb/web/base/partyInfo/PartyInfoHandler.java b/mztb/src/main/java/cc/smtweb/biz/mztb/web/base/partyInfo/PartyInfoHandler.java index f686ba7..bdb3264 100644 --- a/mztb/src/main/java/cc/smtweb/biz/mztb/web/base/partyInfo/PartyInfoHandler.java +++ b/mztb/src/main/java/cc/smtweb/biz/mztb/web/base/partyInfo/PartyInfoHandler.java @@ -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(); + } } diff --git a/mztb/src/main/java/cc/smtweb/biz/mztb/web/base/partyInfo/PartyInfoService.java b/mztb/src/main/java/cc/smtweb/biz/mztb/web/base/partyInfo/PartyInfoService.java index 0bf06da..2955361 100644 --- a/mztb/src/main/java/cc/smtweb/biz/mztb/web/base/partyInfo/PartyInfoService.java +++ b/mztb/src/main/java/cc/smtweb/biz/mztb/web/base/partyInfo/PartyInfoService.java @@ -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)); +} } diff --git a/mztb/src/main/java/cc/smtweb/biz/mztb/web/tool/DbUtil.java b/mztb/src/main/java/cc/smtweb/biz/mztb/web/tool/DbUtil.java index 584bd54..3fd5744 100644 --- a/mztb/src/main/java/cc/smtweb/biz/mztb/web/tool/DbUtil.java +++ b/mztb/src/main/java/cc/smtweb/biz/mztb/web/tool/DbUtil.java @@ -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; } diff --git a/mztb/src/main/resources/static/event/mztb/base/partyInfo/partyInfoCard.js b/mztb/src/main/resources/static/event/mztb/base/partyInfo/partyInfoCard.js new file mode 100644 index 0000000..157e02d --- /dev/null +++ b/mztb/src/main/resources/static/event/mztb/base/partyInfo/partyInfoCard.js @@ -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 + } + } +});