|
|
@@ -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(); |
|
|
|
} |
|
|
|
} |