宜都城投资产数据同步插件
This commit is contained in:
@@ -0,0 +1,45 @@
|
||||
package com.seeyon.apps.src_ydctdatasync;
|
||||
|
||||
import com.seeyon.apps.common.plugin.api.APluginInfoApi;
|
||||
import com.seeyon.apps.common.plugin.vo.ConfigVo;
|
||||
import com.seeyon.apps.src_ydctdatasync.constants.YdzbdataSyncConstants;
|
||||
|
||||
public class YdzbdataSyncPluginApi extends APluginInfoApi {
|
||||
public YdzbdataSyncPluginApi() {
|
||||
}
|
||||
|
||||
public String getPluginId() {
|
||||
System.out.println(YdzbdataSyncConstants.getPluginId());
|
||||
return YdzbdataSyncConstants.getPluginId();
|
||||
}
|
||||
|
||||
public String getCreateUser() {
|
||||
return "橙阳科技";
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return "宜都城投数据同步";
|
||||
}
|
||||
|
||||
public ConfigVo getDefaultConfig() {
|
||||
ConfigVo configVo = new ConfigVo();
|
||||
YdzbdataSyncConstants[] var2 = YdzbdataSyncConstants.values();
|
||||
int var3 = var2.length;
|
||||
|
||||
for(int var4 = 0; var4 < var3; ++var4) {
|
||||
YdzbdataSyncConstants value = var2[var4];
|
||||
if (value != YdzbdataSyncConstants.plugin) {
|
||||
configVo.getDevParams().put(value.name(), value.getDefaultValue());
|
||||
configVo.getProdParams().put(value.name(), value.getDefaultValue());
|
||||
configVo.getParamMap().put(value.name(), value.getDescription());
|
||||
}
|
||||
}
|
||||
|
||||
return configVo;
|
||||
}
|
||||
|
||||
// public void registerCustomEvent(Map eventAndNodes) {
|
||||
// eventAndNodes.put("propertyDispose", "资产管理待办推送");
|
||||
// }
|
||||
}
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
package com.seeyon.apps.src_ydctdatasync.config;
|
||||
|
||||
public class DataSourceConfig {
|
||||
private String url;
|
||||
private String username;
|
||||
private String password;
|
||||
private String driver;
|
||||
public DataSourceConfig() {}
|
||||
|
||||
public DataSourceConfig(String url,String username,String password) {
|
||||
this.url = url;
|
||||
this.username = username;
|
||||
this.password = password;
|
||||
}
|
||||
|
||||
public String getUrl() {
|
||||
return url;
|
||||
}
|
||||
public String getUsername() {
|
||||
return username;
|
||||
}
|
||||
public String getPassword() {
|
||||
return password;
|
||||
}
|
||||
|
||||
public String getDriver() {
|
||||
return driver;
|
||||
}
|
||||
|
||||
public void setDriver(String driver) {
|
||||
this.driver = driver;
|
||||
}
|
||||
|
||||
public void setUrl(String url) {
|
||||
this.url = url;
|
||||
}
|
||||
|
||||
public void setUsername(String username) {
|
||||
this.username = username;
|
||||
}
|
||||
|
||||
public void setPassword(String password) {
|
||||
this.password = password;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
package com.seeyon.apps.src_ydctdatasync.constants;
|
||||
|
||||
public enum YdzbdataSyncConstants {
|
||||
|
||||
|
||||
plugin("YdzbdataSyncConstants","插件ID");
|
||||
|
||||
YdzbdataSyncConstants(String defaultValue, String description) {
|
||||
this.defaultValue = defaultValue;
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
private String defaultValue;
|
||||
private String description;
|
||||
|
||||
public String getDefaultValue() {
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public static String getPluginId() {
|
||||
return plugin.defaultValue;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
package com.seeyon.apps.src_ydctdatasync.dao;
|
||||
|
||||
import com.seeyon.v3x.services.form.bean.RecordExport;
|
||||
import com.seeyon.v3x.services.form.bean.SubordinateFormExport;
|
||||
import com.seeyon.v3x.services.form.bean.ValueExport;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
//创建无流程表单数据处理工具类
|
||||
public class FormExportUtil {
|
||||
|
||||
/**
|
||||
* 设置主表信息
|
||||
* @param map 设置主表字段。Map<主表显示名称,主表数据>
|
||||
* @return
|
||||
*/
|
||||
public static List<ValueExport> setFormValue(Map<String, String> map){
|
||||
// 创建返回值对象
|
||||
List<ValueExport> valueExports = new ArrayList<ValueExport>();
|
||||
ValueExport valueExport ;
|
||||
// 获取参数信息(显示名称)
|
||||
Set<String> keys = map.keySet();
|
||||
if(keys.size()>0) {
|
||||
// 对控件赋值
|
||||
for (String key : keys) {
|
||||
valueExport = new ValueExport();
|
||||
valueExport.setDisplayName(key);
|
||||
valueExport.setValue(map.get(key));
|
||||
valueExports.add(valueExport);
|
||||
}
|
||||
}
|
||||
return valueExports;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置从表信息
|
||||
* @param map 设置主表字段。List<Map<显示名称,数据值>>
|
||||
*/
|
||||
public static List<SubordinateFormExport> setSubordinateFormValue(Map<String, String> map){
|
||||
List<SubordinateFormExport> subordinateFormExports = new ArrayList<SubordinateFormExport>();
|
||||
SubordinateFormExport subordinateFormExport = new SubordinateFormExport();
|
||||
List<Map<String,String>> lists = new ArrayList<>();
|
||||
lists.add(map);
|
||||
List<RecordExport> recordExports = new ArrayList<RecordExport>();
|
||||
List<ValueExport> valueExports;
|
||||
RecordExport recordExport;
|
||||
for(int i = 0 ; i < lists.size() ; i++) {
|
||||
recordExport = new RecordExport();
|
||||
valueExports = setFormValue(lists.get(i));
|
||||
recordExport.setRecord(valueExports);
|
||||
recordExports.add(recordExport);
|
||||
}
|
||||
subordinateFormExport.setValues(recordExports);
|
||||
subordinateFormExports.add(subordinateFormExport);
|
||||
|
||||
return subordinateFormExports;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package com.seeyon.apps.src_ydctdatasync.dao;
|
||||
|
||||
import com.seeyon.ctp.common.exceptions.BusinessException;
|
||||
import com.seeyon.ctp.util.JDBCAgent;
|
||||
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class KsQueryDao {
|
||||
|
||||
public Map<String,Object> queryByName(String name,String clause,String table) throws BusinessException, SQLException {
|
||||
JDBCAgent agent = new JDBCAgent();
|
||||
String sql = "SELECT * FROM" + table + clause +";";
|
||||
List<String> params = new ArrayList<>();
|
||||
agent.execute(sql,params);
|
||||
return agent.resultSetToMap();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,75 @@
|
||||
package com.seeyon.apps.src_ydctdatasync.datamap;
|
||||
|
||||
import com.seeyon.apps.src_ydctdatasync.utils.EnumMapUtils;
|
||||
import com.seeyon.ctp.util.JDBCAgent;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public abstract class AbstractAssetDataMapMode extends AbstractDataMapMode{
|
||||
|
||||
protected JDBCAgent agent;
|
||||
|
||||
@Override
|
||||
public void preProcess(Map<String, Object> map) {
|
||||
Object houseStatus = map.get("house_status");
|
||||
Object propertyMortgage = map.get("property_mortgage");
|
||||
String zcStatus = houseStatus == null ? "" : EnumMapUtils.getEnumItemValue(agent,"资产状态", (String) houseStatus);
|
||||
String isPublicAsset = EnumMapUtils.getEnumItemValue(agent,"是否公用产权","否");
|
||||
String assetBacked = propertyMortgage == null ? "" : EnumMapUtils.getEnumItemValue(agent,"是否产权抵押", (String) propertyMortgage);
|
||||
map.put("house_status",zcStatus);
|
||||
map.put("isPublicAsset",isPublicAsset);
|
||||
map.put("assetBacked",assetBacked);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void commonAttrTransfer(Object target, Object source) {
|
||||
Map<String, Object> targetMap = (Map<String, Object>) target;
|
||||
Map<String, Object> sourceMap = (Map<String, Object>) source;
|
||||
targetMap.put("住保系统编码",sourceMap.get("house_id")); //填充住保系统编码
|
||||
targetMap.put("资产编号",sourceMap.get("house_id")); //填充资产编号
|
||||
StringBuilder stringBuilder = new StringBuilder("");
|
||||
if(sourceMap.get("village_name") != null) {
|
||||
stringBuilder.append(sourceMap.get("village_name"));
|
||||
}
|
||||
if(sourceMap.get("building_name") != null) {
|
||||
if(sourceMap.get("village_name") != null) {
|
||||
stringBuilder.append("_");
|
||||
}
|
||||
stringBuilder.append(sourceMap.get("building_name"));
|
||||
}
|
||||
if(sourceMap.get("variable_001") != null) {
|
||||
if(sourceMap.get("village_name") != null) {
|
||||
stringBuilder.append("_");
|
||||
}
|
||||
stringBuilder.append(sourceMap.get("variable_001"));
|
||||
}
|
||||
if(sourceMap.get("room_number") != null) {
|
||||
if(sourceMap.get("building_name") != null) {
|
||||
stringBuilder.append("_");
|
||||
}
|
||||
stringBuilder.append(sourceMap.get("room_number"));
|
||||
}
|
||||
targetMap.put("资产名称",stringBuilder.toString()); //填充资产名称
|
||||
targetMap.put("资产状态",sourceMap.get("house_status"));//填充资产状态
|
||||
targetMap.put("产权证号",sourceMap.get("property_certificate_no"));//填充产权证号
|
||||
targetMap.put("充产权人",sourceMap.get("property_owner"));//填充产权人
|
||||
targetMap.put("登记时间",sourceMap.get("property_registration_time"));//填充登记时间
|
||||
targetMap.put("是否公用产权",sourceMap.get("isPublicAsset"));//填充是否公用产权
|
||||
targetMap.put("是否产权抵押",sourceMap.get("property_mortgage"));//填充是否产权抵押
|
||||
targetMap.put("建筑面积",sourceMap.get("house_area"));//填充建筑面积
|
||||
targetMap.put("备注-资产信息",sourceMap.get("remark"));//填充备注资产信息
|
||||
targetMap.put("数公基19位编码",sourceMap.get("sgjbm"));//填充数公基19位编码
|
||||
targetMap.put("资产获取日期",sourceMap.get("house_receipt_date"));//填充资产获取日期
|
||||
targetMap.put("账面价值",sourceMap.get("paper_value"));//填充账面价值
|
||||
targetMap.put("租赁基准价格",sourceMap.get("rent_benchmark"));//填充租赁基准价格
|
||||
// targetMap.put("field0061",sourceMap.get(""));//填充管理单位编号
|
||||
}
|
||||
|
||||
public JDBCAgent getAgent() {
|
||||
return agent;
|
||||
}
|
||||
|
||||
public void setAgent(JDBCAgent agent) {
|
||||
this.agent = agent;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package com.seeyon.apps.src_ydctdatasync.datamap;
|
||||
|
||||
import com.seeyon.ctp.util.JDBCAgent;
|
||||
|
||||
public abstract class AbstractContractDataMapMode extends AbstractDataMapMode{
|
||||
|
||||
protected JDBCAgent agent;
|
||||
|
||||
@Override
|
||||
public void commonAttrTransfer(Object target, Object source) {
|
||||
|
||||
}
|
||||
|
||||
public JDBCAgent getAgent() {
|
||||
return agent;
|
||||
}
|
||||
|
||||
public void setAgent(JDBCAgent agent) {
|
||||
this.agent = agent;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
package com.seeyon.apps.src_ydctdatasync.datamap;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.function.Function;
|
||||
|
||||
public abstract class AbstractDataMapMode {
|
||||
/**
|
||||
* 表级别的前置处理,适用于一张表的整体逻辑
|
||||
*/
|
||||
public abstract void preProcess(Map<String, Object> map);
|
||||
|
||||
/**
|
||||
* 返回字段级别的处理逻辑映射,每个字段对应一个处理函数
|
||||
* @return 字段与其处理函数的映射
|
||||
*/
|
||||
public abstract Map<String, Function<Object, Object>> getFieldProcessors();
|
||||
|
||||
/**
|
||||
* 判断当前模式是否支持
|
||||
*/
|
||||
public abstract boolean support();
|
||||
|
||||
/**
|
||||
* 实现记录级别的目标源映射
|
||||
* @param target 目标对象
|
||||
* @param source 源对象
|
||||
*/
|
||||
public abstract void transfer(Object target, Object source);
|
||||
|
||||
/**
|
||||
* 实现记录级别的共有字段的映射
|
||||
* @param target 目标对象
|
||||
* @param source 源对象
|
||||
*/
|
||||
public abstract void commonAttrTransfer(Object target, Object source);
|
||||
|
||||
/**
|
||||
* 数据映射,包含字段级和记录级的处理逻辑
|
||||
* @param target 目标对象
|
||||
* @param source 源对象
|
||||
*/
|
||||
protected void dataMapping(Object target, Object source) {
|
||||
if (source instanceof Map && target instanceof Map) {
|
||||
Map<String, Object> sourceMap = (Map<String, Object>) source;
|
||||
Map<String, Object> targetMap = (Map<String, Object>) target;
|
||||
preProcess(sourceMap); // 表级别前置处理
|
||||
Map<String, Function<Object, Object>> sourcefieldProcessors = getFieldProcessors();
|
||||
|
||||
for (Map.Entry<String, Object> entry : sourceMap.entrySet()) {
|
||||
String fieldName = entry.getKey();
|
||||
Object fieldValue = entry.getValue();
|
||||
// 查找字段处理逻辑
|
||||
Function<Object, Object> processor = sourcefieldProcessors.getOrDefault(fieldName, this::defaultFieldProcessor);
|
||||
Object processedValue = processor.apply(fieldValue);
|
||||
sourceMap.put(fieldName, processedValue); // 处理后的值覆盖源值
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
transfer(target, source); // 记录级别处理
|
||||
}
|
||||
|
||||
/**
|
||||
* 默认字段处理逻辑,未定义处理方式的字段调用此方法
|
||||
* @param fieldValue 字段值
|
||||
* @return 原始字段值(默认不处理)
|
||||
*/
|
||||
protected Object defaultFieldProcessor(Object fieldValue) {
|
||||
return fieldValue;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
package com.seeyon.apps.src_ydctdatasync.datamap;
|
||||
|
||||
import com.seeyon.ctp.util.JDBCAgent;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public abstract class AbstractFeeDataMapMode extends AbstractDataMapMode{
|
||||
|
||||
protected JDBCAgent agent;
|
||||
|
||||
@Override
|
||||
public void preProcess(Map<String, Object> map) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void commonAttrTransfer(Object target, Object source) {
|
||||
Map<String, Object> targetMap = (Map<String, Object>) target;
|
||||
Map<String, Object> sourceMap = (Map<String, Object>) source;
|
||||
targetMap.put("数据来源","住保系统集成获取的收支数据"); //填充数据来源
|
||||
targetMap.put("住保-合同编号",sourceMap.get("contract_no")); //填充合同编号
|
||||
targetMap.put("合同ID",sourceMap.get("contract_id")); //填充合同ID
|
||||
targetMap.put("住保系统编码",sourceMap.get("house_id")); //住保系统编码
|
||||
targetMap.put("住保-小区",sourceMap.get("village_name")); //填充小区
|
||||
targetMap.put("住保-楼栋",sourceMap.get("building_name")); //填充楼栋
|
||||
targetMap.put("住保-单元",sourceMap.get("unit_name")); //填充单元
|
||||
targetMap.put("住保-房号",sourceMap.get("house_number")); //填充房号
|
||||
targetMap.put("住保-租户联系方式",sourceMap.get("tenant_phone_number")); //填充租户联系方式
|
||||
targetMap.put("OA付款单位","默认宜都市住保运营管理有限公司"); //填充OA付款单位,默认宜都市住保运营管理有限公司
|
||||
targetMap.put("OA收款单位","默认宜都市住保运营管理有限公司"); //填充OA收款单位,默认宜都市住保运营管理有限公司
|
||||
}
|
||||
|
||||
public JDBCAgent getAgent() {
|
||||
return agent;
|
||||
}
|
||||
|
||||
public void setAgent(JDBCAgent agent) {
|
||||
this.agent = agent;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,173 @@
|
||||
package com.seeyon.apps.src_ydctdatasync.datamap;
|
||||
|
||||
import com.seeyon.apps.src_ydctdatasync.dao.FormExportUtil;
|
||||
import com.seeyon.apps.src_ydctdatasync.datasource.DataSource;
|
||||
import com.seeyon.apps.src_ydctdatasync.utils.EnumMapUtils;
|
||||
import com.seeyon.ctp.common.AppContext;
|
||||
import com.seeyon.ctp.common.exceptions.BusinessException;
|
||||
import com.seeyon.ctp.organization.bo.V3xOrgDepartment;
|
||||
import com.seeyon.ctp.organization.bo.V3xOrgMember;
|
||||
import com.seeyon.ctp.organization.manager.OrgManager;
|
||||
import com.seeyon.ctp.util.JDBCAgent;
|
||||
import com.seeyon.v3x.services.form.FormFactory;
|
||||
import com.seeyon.v3x.services.form.bean.FormExport;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.function.Function;
|
||||
|
||||
//保障房资产映射OA资产表模式
|
||||
public class BzfAssetMode extends AbstractAssetDataMapMode{
|
||||
|
||||
private DataSource localDataSource;
|
||||
private FormFactory formFactory;
|
||||
|
||||
public FormFactory getFormFactory() {
|
||||
if (formFactory == null) {
|
||||
formFactory = (FormFactory) AppContext.getBean("formFactory");
|
||||
}
|
||||
return formFactory;
|
||||
}
|
||||
|
||||
public void setFormFactory(FormFactory formFactory) {
|
||||
this.formFactory = formFactory;
|
||||
}
|
||||
|
||||
public DataSource getLocalDataSource() {
|
||||
return localDataSource;
|
||||
}
|
||||
|
||||
public void setLocalDataSource(DataSource localDataSource) {
|
||||
this.localDataSource = localDataSource;
|
||||
}
|
||||
|
||||
private void enumMap(Map<String, Object> sourceMap) {
|
||||
String xqzcpLevelValue = EnumMapUtils.getEnumItemValue(agent,"资产层级","父级");
|
||||
String zcTypeFwValue = EnumMapUtils.getEnumItemValue(agent,"资产类型","房屋");
|
||||
String zcTypeLevel2 = EnumMapUtils.getEnumItemValue(agent,"资产二级类型","保障性住房");
|
||||
String xqzcBlock = EnumMapUtils.getEnumItemValue(agent,"资产板块","03不动产");
|
||||
String xqzcStatus = EnumMapUtils.getEnumItemValue(agent,"资产状态","待出租");
|
||||
String xqzcFeature = EnumMapUtils.getEnumItemValue(agent,"资产性质","非流动资产");
|
||||
String xqzz = EnumMapUtils.getEnumItemValue(agent,"用途","住宅");
|
||||
String house_use = EnumMapUtils.getEnumItemValue(agent,"用途", (String) sourceMap.get("house_use"));
|
||||
String rental_type = EnumMapUtils.getEnumItemValue(agent,"租售类型",(String) sourceMap.get("rental_type"));
|
||||
String xqrental_type = EnumMapUtils.getEnumItemValue(agent,"租售类型","只租不售");
|
||||
String xqhs = EnumMapUtils.getEnumItemValue(agent,"房屋体系","保租房");
|
||||
String hs = EnumMapUtils.getEnumItemValue(agent,"房屋体系",(String) sourceMap.get("house_system"));
|
||||
String land_nature = EnumMapUtils.getEnumItemValue(agent,"土地性质", (String) sourceMap.get("land_nature"));
|
||||
String house_type = EnumMapUtils.getEnumItemValue(agent,"户型", (String) sourceMap.get("house_type"));
|
||||
String has_lift = EnumMapUtils.getEnumItemValue(agent,"有无电梯", (String) sourceMap.get("has_lift"));
|
||||
String raise_way = EnumMapUtils.getEnumItemValue(agent,"筹集方式", (String) sourceMap.get("raise_way"));
|
||||
sourceMap.put("xqzcpLevel",xqzcpLevelValue);
|
||||
sourceMap.put("zcTypeFwValue",zcTypeFwValue);
|
||||
sourceMap.put("zcTypeLevel2",zcTypeLevel2);
|
||||
sourceMap.put("xqzcBlock",xqzcBlock);
|
||||
sourceMap.put("xqzcStatus",xqzcStatus);
|
||||
sourceMap.put("xqzcFeature",xqzcFeature);
|
||||
sourceMap.put("xqrental_type",xqrental_type);
|
||||
sourceMap.put("xqhs",xqhs);
|
||||
sourceMap.put("xqzz",xqzz);
|
||||
sourceMap.put("house_use",house_use);
|
||||
sourceMap.put("land_nature",land_nature);
|
||||
sourceMap.put("rental_type",rental_type);
|
||||
sourceMap.put("house_system",hs);
|
||||
sourceMap.put("house_type",house_type);
|
||||
sourceMap.put("has_lift",has_lift);
|
||||
sourceMap.put("raise_way",raise_way);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void preProcess(Map<String, Object> sourceMap) {
|
||||
FormExport formExport = new FormExport();
|
||||
String loginName = (String) sourceMap.get("loginName");
|
||||
//查询客商档案以及填充
|
||||
//处理小区资产档案信息
|
||||
super.preProcess(sourceMap);
|
||||
enumMap(sourceMap);
|
||||
try {
|
||||
List<String> params = new ArrayList<>();
|
||||
params.add((String) sourceMap.get("xqzcpLevelValue"));
|
||||
params.add((String) sourceMap.get("zcTypeFwValue"));
|
||||
params.add((String) sourceMap.get("village_name"));
|
||||
String villageQuerySql = "SELECT 1 FROM formmain_0934 WHERE field0027 = ? and field0023 = ? and field0037 =?;";
|
||||
agent.execute(villageQuerySql, params);
|
||||
List resList = agent.resultSetToList();
|
||||
if(resList == null || resList.size() == 0) {
|
||||
//保障性住房小区的资产信息若不存在,则插入
|
||||
Map<String,String> villageInsertInfo = new HashMap<>();
|
||||
villageInsertInfo.put("建档部门",getCreatorDept(agent,loginName));//建档部门
|
||||
villageInsertInfo.put("建档人员","系统管理员");//建档人员
|
||||
villageInsertInfo.put("建档日期",new Date()+"");//建档日期
|
||||
villageInsertInfo.put("资产板块",sourceMap.get("xqzcBlock")+"");//资产板块
|
||||
villageInsertInfo.put("建档单位","住保置业");//建档单位
|
||||
villageInsertInfo.put("资产层级",sourceMap.get("xqzcpLevelValue")+"");//资产层级
|
||||
villageInsertInfo.put("数据来源","住保资产系统(自定义)");//数据来源
|
||||
villageInsertInfo.put("资产名称",sourceMap.get("village_name") + "");//资产名称
|
||||
villageInsertInfo.put("资产状态",sourceMap.get("xqzcStatus") + "");//资产状态
|
||||
villageInsertInfo.put("资产性质",sourceMap.get("xqzcFeature") + "");//资产性质
|
||||
villageInsertInfo.put("资产类型",sourceMap.get("zcTypeFwValue") + "");//资产类型
|
||||
villageInsertInfo.put("资产二级类型",sourceMap.get("zcTypeLevel2") + "");//资产二级类型
|
||||
villageInsertInfo.put("资产种类","保障性住房");//资产种类
|
||||
villageInsertInfo.put("所属小区",sourceMap.get("village_name") +"");//小区
|
||||
villageInsertInfo.put("用途",sourceMap.get("house_use") +"");//用途
|
||||
villageInsertInfo.put("租售类型",sourceMap.get("xqrental_type") +"");//租售类型
|
||||
villageInsertInfo.put("/房屋体系",sourceMap.get("house_system") +"");//房屋体系
|
||||
// villageInsertInfo.put("field0058",sourceMap.get(""));//坐落位置
|
||||
villageInsertInfo.put("土地性质",sourceMap.get("land_nature") +"");//土地性质
|
||||
villageInsertInfo.put("是否产权抵押",sourceMap.get("assetBacked") +""); //是否产权抵押
|
||||
formExport.setValues(FormExportUtil.setFormValue(villageInsertInfo));
|
||||
getFormFactory().importBusinessFormData(loginName, "zcbd1",formExport, new String[] {});
|
||||
}
|
||||
}catch (Exception e) {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private String getCreatorDept(JDBCAgent agent,String loginName) {
|
||||
OrgManager orgManager = (OrgManager) AppContext.getBean("orgManager");
|
||||
try {
|
||||
V3xOrgMember member = orgManager.getMemberByLoginName(loginName);
|
||||
Long departmentId = member.getOrgDepartmentId();
|
||||
V3xOrgDepartment department = orgManager.getDepartmentById(departmentId);
|
||||
return department == null ? "" : department.getName();
|
||||
} catch (BusinessException e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Function<Object, Object>> getFieldProcessors() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean support() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void transfer(Object target, Object source) {
|
||||
Map<String, Object> targetMap = (Map<String, Object>) target;
|
||||
Map<String, Object> sourceMap = (Map<String, Object>) source;
|
||||
targetMap.put("资产类型",sourceMap.get("zcTypeFwValue"));//填充资产类型
|
||||
targetMap.put("资产二级类型",sourceMap.get("zcTypeLevel2"));//填充资产二级类型
|
||||
targetMap.put("楼栋",sourceMap.get("building_name"));//填充楼栋
|
||||
targetMap.put("单元",sourceMap.get("unit_name"));//填充单元
|
||||
targetMap.put("具体楼层",sourceMap.get("specific_floor"));//填充具体楼层
|
||||
targetMap.put("房屋朝向",sourceMap.get("house_orientation"));//填充房屋朝向
|
||||
targetMap.put("户型",sourceMap.get("house_type"));//填充户型
|
||||
targetMap.put("有无电梯",sourceMap.get("has_lift"));//填充有无电梯
|
||||
targetMap.put("用途",sourceMap.get("house_use"));//填充用途
|
||||
targetMap.put("房屋体系",sourceMap.get("house_system"));//填充房屋体系
|
||||
targetMap.put("租售类型",sourceMap.get("rental_type"));//填充租售类型
|
||||
targetMap.put("筹集方式",sourceMap.get("raise_way"));//填充筹集方式
|
||||
targetMap.put("所属小区",sourceMap.get("village_name"));//填充所属小区
|
||||
targetMap.put("土地性质",sourceMap.get("land_nature"));//填充土地性质
|
||||
|
||||
targetMap.put("房号",sourceMap.get("room_number"));//填充房号
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
package com.seeyon.apps.src_ydctdatasync.datamap;
|
||||
|
||||
|
||||
import com.seeyon.apps.src_ydctdatasync.utils.EnumMapUtils;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.function.Function;
|
||||
|
||||
public class ContractBillMode extends AbstractFeeDataMapMode{
|
||||
|
||||
|
||||
@Override
|
||||
public void preProcess(Map<String, Object> map) {
|
||||
String recordBill = EnumMapUtils.getEnumItemValue(agent,"是否入账","未入");
|
||||
String incomeOrCost = EnumMapUtils.getEnumItemValue(agent,"收支类型","收");
|
||||
map.put("recordBill",recordBill);
|
||||
map.put("incomeOrCost",incomeOrCost);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Function<Object, Object>> getFieldProcessors() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean support() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void transfer(Object target, Object source) {
|
||||
Map<String, Object> targetMap = (Map<String, Object>) target;
|
||||
Map<String, Object> sourceMap = (Map<String, Object>) source;
|
||||
targetMap.put("是否入账",sourceMap.get("recordBill")); //填充是否入账
|
||||
targetMap.put("收支类型",sourceMap.get("incomeOrCost")); //填充收支类型
|
||||
targetMap.put("住保-费用类型",sourceMap.get("bill_type")); //填充费用类型
|
||||
targetMap.put("主键",sourceMap.get("bill_id")); //主键
|
||||
targetMap.put("应收金额",sourceMap.get("bill_amount")); //填充应收金额
|
||||
targetMap.put("本次实收金额",sourceMap.get("bill_amount")); //填充本次实收金额
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,107 @@
|
||||
package com.seeyon.apps.src_ydctdatasync.datamap;
|
||||
|
||||
import com.seeyon.apps.src_ydctdatasync.dao.KsQueryDao;
|
||||
import com.seeyon.apps.src_ydctdatasync.utils.EnumMapUtils;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.function.Function;
|
||||
|
||||
public class ContractMode extends AbstractContractDataMapMode {
|
||||
|
||||
@Override
|
||||
public void preProcess(Map<String, Object> map) {
|
||||
String zcType = EnumMapUtils.getEnumItemValue(agent,"资产类型","房屋");
|
||||
String zcBlock = EnumMapUtils.getEnumItemValue(agent,"资产板块","03不动产");
|
||||
String ksName = (String) map.get("b_name");
|
||||
String zcTypeLevel2 = (String) map.get("asset_type_name");
|
||||
if(zcTypeLevel2.equals("保障房")){
|
||||
map.put("asset_type_name","保障性住房");
|
||||
}else if(zcTypeLevel2.equals("国资门面")) {
|
||||
map.put("asset_type_name","住宅");
|
||||
}else {
|
||||
map.put("asset_type_name","厂房");
|
||||
}
|
||||
map.put("zcType",zcType);
|
||||
map.put("zcBlock",zcBlock);
|
||||
map.put("asset_type_name",EnumMapUtils.getEnumItemValue(agent,"资产二级类型", (String) map.get("asset_type_name")));
|
||||
KsQueryDao ksQueryDao = new KsQueryDao();
|
||||
try {
|
||||
Map<String, Object> ksMap = ksQueryDao.queryByName(ksName, "where field0006 = ?", ksName);
|
||||
if(map != null && !map.isEmpty()) {
|
||||
map.put("u8ccode",ksMap.get("field0092"));
|
||||
map.put("signCorpNo",ksMap.get("field0029"));
|
||||
}
|
||||
} catch (Exception e) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Function<Object, Object>> getFieldProcessors() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean support() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void transfer(Object target, Object source) {
|
||||
Map<String, Object> targetMap = (Map<String, Object>) target;
|
||||
Map<String, Object> sourceMap = (Map<String, Object>) source;
|
||||
Map<String,Object> subTableMap = new HashMap<>();
|
||||
|
||||
targetMap.put("subTable",subTableMap);
|
||||
targetMap.put("合同ID",sourceMap.get("contract_id")); //填充合同ID
|
||||
targetMap.put("合同编号",sourceMap.get("contract_no")); //填充合同编号
|
||||
targetMap.put("签订单位编号",sourceMap.get("signCorpNo")); //填充签订单位编号
|
||||
targetMap.put("签订单位",sourceMap.get("a_name"));//填充签订单位
|
||||
targetMap.put("合同金额",sourceMap.get("contract_total_amount"));//合同金额
|
||||
targetMap.put("合同开始日期",sourceMap.get("tenant_start_time"));//合同开始日期
|
||||
targetMap.put("合同截止日期",sourceMap.get("tenant_end_time"));//合同截止日期
|
||||
targetMap.put("U8C客商编号",sourceMap.get("u8ccode"));//U8C客商编号
|
||||
targetMap.put("客商名称",sourceMap.get("b_name"));//客商名称
|
||||
targetMap.put("联系方式",sourceMap.get("b_connect"));//联系方式
|
||||
targetMap.put("甲方名称",sourceMap.get("a_name"));//甲方名称
|
||||
targetMap.put("乙方名称",sourceMap.get("b_name"));//乙方名称
|
||||
targetMap.put("合同状态",sourceMap.get("contract_state"));//合同状态
|
||||
targetMap.put("累计已收租金",sourceMap.get("contract_receive_amount"));//累计已收租金
|
||||
targetMap.put("剩余未收租金",sourceMap.get("contract_remaining_amount"));//剩余未收租金
|
||||
|
||||
//填充子表
|
||||
subTableMap.put("不动产板块",sourceMap.get("zcBlock"));//资产板块
|
||||
subTableMap.put("资产类型",sourceMap.get("zcType"));//资产类型
|
||||
subTableMap.put("资产二级类型",sourceMap.get("asset_type_name"));//资产二级类型
|
||||
subTableMap.put("所属小区",sourceMap.get("village_name")); //填充小区名
|
||||
subTableMap.put("楼栋",sourceMap.get("building_name")); //填充楼栋
|
||||
subTableMap.put("单元",sourceMap.get("unit_name")); //填充单元
|
||||
subTableMap.put("房号",sourceMap.get("house_number")); //填充房号
|
||||
subTableMap.put("住保资产编号",sourceMap.get("house_id"));
|
||||
subTableMap.put("OA资产编号",sourceMap.get("house_id"));
|
||||
StringBuilder stringBuilder = new StringBuilder("");
|
||||
if(sourceMap.get("village_name") != null) {
|
||||
stringBuilder.append(sourceMap.get("village_name"));
|
||||
}
|
||||
if(sourceMap.get("building_name") != null) {
|
||||
if(sourceMap.get("village_name") != null) {
|
||||
stringBuilder.append("_");
|
||||
}
|
||||
stringBuilder.append(sourceMap.get("building_name"));
|
||||
}
|
||||
if(sourceMap.get("variable_001") != null) {
|
||||
if(sourceMap.get("village_name") != null) {
|
||||
stringBuilder.append("_");
|
||||
}
|
||||
stringBuilder.append(sourceMap.get("variable_001"));
|
||||
}
|
||||
if(sourceMap.get("room_number") != null) {
|
||||
if(sourceMap.get("building_name") != null) {
|
||||
stringBuilder.append("_");
|
||||
}
|
||||
stringBuilder.append(sourceMap.get("room_number"));
|
||||
}
|
||||
subTableMap.put("资产名称",stringBuilder.toString()); //填充资产名称
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
package com.seeyon.apps.src_ydctdatasync.datamap;
|
||||
|
||||
import com.seeyon.apps.src_ydctdatasync.utils.EnumMapUtils;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.function.Function;
|
||||
|
||||
public class GzcfAssetMode extends AbstractAssetDataMapMode{
|
||||
|
||||
|
||||
@Override
|
||||
public void preProcess(Map<String, Object> map) {
|
||||
super.preProcess(map);
|
||||
String has_lift = EnumMapUtils.getEnumItemValue(agent,"有无电梯", (String) map.get("has_lift"));
|
||||
String zcTypeFwValue = EnumMapUtils.getEnumItemValue(agent,"资产类型","房屋");
|
||||
String zcTypeLevel2 = EnumMapUtils.getEnumItemValue(agent,"资产二级类型","厂房");
|
||||
String house_use = EnumMapUtils.getEnumItemValue(agent,"用途", (String) map.get("house_use"));
|
||||
map.put("zcTypeFwValue",zcTypeFwValue);
|
||||
map.put("zcTypeLevel2",zcTypeLevel2);
|
||||
map.put("has_lift",has_lift);
|
||||
map.put("house_use",house_use);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Function<Object, Object>> getFieldProcessors() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean support() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void transfer(Object target, Object source) {
|
||||
Map<String, Object> targetMap = (Map<String, Object>) target;
|
||||
Map<String, Object> sourceMap = (Map<String, Object>) source;
|
||||
targetMap.put("资产类型",sourceMap.get("zcTypeFwValue"));//填充资产类型
|
||||
targetMap.put("资产二级类型",sourceMap.get("zcTypeLevel2"));//填充资产二级类型
|
||||
targetMap.put("坐落位置",sourceMap.get("located_street"));//填充坐落位置
|
||||
targetMap.put("有无电梯",sourceMap.get("has_lift"));//填充有无电梯
|
||||
targetMap.put("用途",sourceMap.get("house_use"));//填充房屋用途
|
||||
|
||||
targetMap.put("房号",sourceMap.get("room_number"));//填充房号
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
package com.seeyon.apps.src_ydctdatasync.datamap;
|
||||
|
||||
|
||||
import com.seeyon.apps.src_ydctdatasync.utils.EnumMapUtils;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Map;
|
||||
import java.util.function.Function;
|
||||
|
||||
public class GzfwAssetMode extends AbstractAssetDataMapMode{
|
||||
|
||||
@Override
|
||||
public void preProcess(Map<String, Object> map) {
|
||||
super.preProcess(map);
|
||||
String zcTypeFwValue = EnumMapUtils.getEnumItemValue(agent,"资产类型","房屋");
|
||||
String zcTypeLevel2 = EnumMapUtils.getEnumItemValue(agent,"资产二级类型","住宅");
|
||||
String has_lift = EnumMapUtils.getEnumItemValue(agent,"有无电梯", (String) map.get("has_lift"));
|
||||
String house_use = EnumMapUtils.getEnumItemValue(agent,"用途", (String) map.get("house_use"));
|
||||
String house_type = EnumMapUtils.getEnumItemValue(agent,"房屋类型", (String) map.get("variable_002"));
|
||||
map.put("zcTypeFwValue",zcTypeFwValue);
|
||||
map.put("zcTypeLevel2",zcTypeLevel2);
|
||||
map.put("has_lift",has_lift);
|
||||
map.put("house_use",house_use);
|
||||
map.put("variable_002",house_type);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Function<Object, Object>> getFieldProcessors() {
|
||||
return Collections.emptyMap();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean support() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void transfer(Object target, Object source) {
|
||||
Map<String, Object> targetMap = (Map<String, Object>) target;
|
||||
Map<String, Object> sourceMap = (Map<String, Object>) source;
|
||||
targetMap.put("资产类型",sourceMap.get("zcTypeFwValue"));//填充资产类型
|
||||
targetMap.put("资产二级类型",sourceMap.get("zcTypeLevel2"));//填充资产二级类型
|
||||
targetMap.put("资产种类",sourceMap.get("variable_002"));//填充资产种类
|
||||
targetMap.put("楼栋",sourceMap.get("variable_001"));//填充楼栋
|
||||
targetMap.put("坐落位置",sourceMap.get("located_street"));//填充坐落位置
|
||||
targetMap.put("有无电梯",sourceMap.get("has_lift"));//填充有无电梯
|
||||
targetMap.put("用途",sourceMap.get("house_use"));//填充房屋用途
|
||||
|
||||
targetMap.put("房号",sourceMap.get("room_number"));//填充房号
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
package com.seeyon.apps.src_ydctdatasync.datamap;
|
||||
|
||||
import com.seeyon.apps.src_ydctdatasync.utils.EnumMapUtils;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Map;
|
||||
import java.util.function.Function;
|
||||
|
||||
public class GztdAssetMode extends AbstractAssetDataMapMode{
|
||||
|
||||
@Override
|
||||
public void preProcess(Map<String, Object> map) {
|
||||
super.preProcess(map);
|
||||
String zcTypeFwValue = EnumMapUtils.getEnumItemValue(agent,"资产类型","土地");
|
||||
String zcTypeLevel2 = EnumMapUtils.getEnumItemValue(agent,"资产二级类型","自用出让地");
|
||||
String land_nature = EnumMapUtils.getEnumItemValue(agent,"土地性质", (String) map.get("land_nature"));
|
||||
map.put("zcTypeFwValue",zcTypeFwValue);
|
||||
map.put("zcTypeLevel2",zcTypeLevel2);
|
||||
map.put("land_nature",land_nature);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Function<Object, Object>> getFieldProcessors() {
|
||||
return Collections.emptyMap();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean support() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void transfer(Object target, Object source) {
|
||||
Map<String, Object> targetMap = (Map<String, Object>) target;
|
||||
Map<String, Object> sourceMap = (Map<String, Object>) source;
|
||||
targetMap.put("资产类型",sourceMap.get("zcTypeFwValue"));//填充资产类型
|
||||
targetMap.put("资产二级类型",sourceMap.get("zcTypeLevel2"));//填充资产二级类型
|
||||
targetMap.put("坐落位置",sourceMap.get("located_street"));//填充坐落位置
|
||||
targetMap.put("土地性质",sourceMap.get("land_nature"));//填充土地性质
|
||||
// targetMap.put("field0079",sourceMap.get(""));//填充资产所属单位
|
||||
// targetMap.put("field0062",sourceMap.get(""));//填充管理单位
|
||||
// targetMap.put("field0204",sourceMap.get(""));//填充建设单位编号
|
||||
// targetMap.put("field0205",sourceMap.get(""));//填充建设单位
|
||||
// targetMap.put("field0063",sourceMap.get(""));//填充建设产权单位编号
|
||||
// targetMap.put("field0064",sourceMap.get(""));//填充建设产权单位
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
package com.seeyon.apps.src_ydctdatasync.datamap;
|
||||
|
||||
import com.seeyon.apps.src_ydctdatasync.utils.EnumMapUtils;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Map;
|
||||
import java.util.function.Function;
|
||||
|
||||
public class HydropowerRechargeDataMapMode extends AbstractFeeDataMapMode{
|
||||
|
||||
@Override
|
||||
public void preProcess(Map<String, Object> map) {
|
||||
super.preProcess(map);
|
||||
String incomeOrCost = EnumMapUtils.getEnumItemValue(agent,"收支类型","收");
|
||||
map.put("incomeOrCost",incomeOrCost);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Function<Object, Object>> getFieldProcessors() {
|
||||
return Collections.emptyMap();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean support() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void transfer(Object target, Object source) {
|
||||
Map<String, Object> targetMap = (Map<String, Object>) target;
|
||||
Map<String, Object> sourceMap = (Map<String, Object>) source;
|
||||
targetMap.put("收支类型",sourceMap.get("incomeOrCost")); //填充收支类型
|
||||
targetMap.put("到账日期",sourceMap.get("recharge_time")); //填充到账日期
|
||||
targetMap.put("住保-费用类型","水电费"); //填充费用类型
|
||||
targetMap.put("住保-账单生成日期",sourceMap.get("recharge_time")); //填充账单生成日期
|
||||
targetMap.put("实收日期",sourceMap.get("recharge_time")); //填充实收日期
|
||||
targetMap.put("住保-支付订单状态",sourceMap.get("recharge_status")); //填充订单状态
|
||||
targetMap.put("订单描述说明",sourceMap.get("recharge_desc")); //填充订单说明
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
package com.seeyon.apps.src_ydctdatasync.datamap;
|
||||
|
||||
import com.seeyon.apps.src_ydctdatasync.utils.EnumMapUtils;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Map;
|
||||
import java.util.function.Function;
|
||||
|
||||
public class RefundDataMapMode extends AbstractFeeDataMapMode{
|
||||
|
||||
@Override
|
||||
public void preProcess(Map<String, Object> map) {
|
||||
super.preProcess(map);
|
||||
String incomeOrCost = EnumMapUtils.getEnumItemValue(agent,"收支类型","支");
|
||||
map.put("incomeOrCost",incomeOrCost);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Function<Object, Object>> getFieldProcessors() {
|
||||
return Collections.emptyMap();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean support() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void transfer(Object target, Object source) {
|
||||
Map<String, Object> targetMap = (Map<String, Object>) target;
|
||||
Map<String, Object> sourceMap = (Map<String, Object>) source;
|
||||
targetMap.put("收支类型",sourceMap.get("incomeOrCost")); //填充收支类型
|
||||
targetMap.put("住保-费用类型",sourceMap.get("refund_type")); //填充费用类型
|
||||
targetMap.put("住保-支付订单状态",sourceMap.get("refund_status")); //填充订单状态
|
||||
targetMap.put("订单描述说明",sourceMap.get("recharge_desc")); //填充订单说明
|
||||
targetMap.put("本次实付金额",sourceMap.get("refund_amount")); //填充本次实付金额
|
||||
targetMap.put("住保-退还账单时间",sourceMap.get("refund_bill_time")); //填充退还账单时间
|
||||
targetMap.put("实付日期",sourceMap.get("refund_time")); //填充实付日期
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,129 @@
|
||||
package com.seeyon.apps.src_ydctdatasync.datasource;
|
||||
|
||||
import com.seeyon.apps.src_ydctdatasync.config.DataSourceConfig;
|
||||
|
||||
import java.lang.reflect.InvocationHandler;
|
||||
import java.lang.reflect.Method;
|
||||
import java.lang.reflect.Proxy;
|
||||
import java.sql.Connection;
|
||||
import java.sql.DriverManager;
|
||||
import java.sql.SQLException;
|
||||
import java.util.Queue;
|
||||
import java.util.concurrent.BlockingQueue;
|
||||
import java.util.concurrent.ConcurrentLinkedQueue;
|
||||
import java.util.concurrent.LinkedBlockingQueue;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
public class DataSource {
|
||||
private DataSourceConfig config;
|
||||
private final int maximumPoolSize = 5;
|
||||
private final int minimumIdle = 3;
|
||||
// 连接队列
|
||||
private final BlockingQueue<Connection> idleConnections = new LinkedBlockingQueue<>();
|
||||
private final Queue<Connection> activeConnections = new ConcurrentLinkedQueue<>();
|
||||
|
||||
// 构造方法
|
||||
public DataSource() {
|
||||
|
||||
}
|
||||
|
||||
public DataSourceConfig getConfig() {
|
||||
return config;
|
||||
}
|
||||
|
||||
public void setConfig(DataSourceConfig config) {
|
||||
this.config = config;
|
||||
}
|
||||
|
||||
// 创建一个新的数据库连接
|
||||
private Connection createNewConnection() {
|
||||
try {
|
||||
Class.forName(config.getDriver());
|
||||
Connection realConnection = DriverManager.getConnection(config.getUrl(),config.getUsername(), config.getPassword());
|
||||
return (Connection) Proxy.newProxyInstance(
|
||||
realConnection.getClass().getClassLoader(),
|
||||
new Class[]{Connection.class},
|
||||
new ConnectionProxyHandler(realConnection, this)
|
||||
);
|
||||
} catch (SQLException e) {
|
||||
throw new RuntimeException("Failed to create a new connection", e);
|
||||
} catch (ClassNotFoundException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// 从连接池获取连接
|
||||
public Connection getConnection() throws SQLException {
|
||||
Connection connection = idleConnections.poll();
|
||||
if (connection == null) {
|
||||
synchronized (this) {
|
||||
if (activeConnections.size() + idleConnections.size() < maximumPoolSize) {
|
||||
connection = createNewConnection();
|
||||
} else {
|
||||
try {
|
||||
// 等待空闲连接释放
|
||||
connection = idleConnections.poll(10, TimeUnit.SECONDS);
|
||||
if (connection == null) {
|
||||
throw new SQLException("No available connection in the pool");
|
||||
}
|
||||
} catch (InterruptedException e) {
|
||||
throw new SQLException("Interrupted while waiting for a connection", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (connection != null) {
|
||||
activeConnections.offer(connection);
|
||||
}
|
||||
|
||||
return connection;
|
||||
}
|
||||
|
||||
// 归还连接到连接池
|
||||
public void releaseConnection(Connection connection) {
|
||||
if (connection != null) {
|
||||
activeConnections.remove(connection);
|
||||
idleConnections.offer(connection);
|
||||
}
|
||||
}
|
||||
|
||||
// 销毁连接池中的所有连接
|
||||
public void close() {
|
||||
for (Connection connection : idleConnections) {
|
||||
closeConnection(connection);
|
||||
}
|
||||
for (Connection connection : activeConnections) {
|
||||
closeConnection(connection);
|
||||
}
|
||||
}
|
||||
|
||||
private void closeConnection(Connection connection) {
|
||||
try {
|
||||
connection.close();
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
// 代理处理器,用于拦截 close 方法
|
||||
private class ConnectionProxyHandler implements InvocationHandler {
|
||||
private final Connection realConnection;
|
||||
private final DataSource pool;
|
||||
|
||||
public ConnectionProxyHandler(Connection realConnection, DataSource pool) {
|
||||
this.realConnection = realConnection;
|
||||
this.pool = pool;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
|
||||
if ("close".equals(method.getName())) {
|
||||
pool.releaseConnection((Connection) proxy);
|
||||
return null;
|
||||
}
|
||||
return method.invoke(realConnection, args);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,426 @@
|
||||
package com.seeyon.apps.src_ydctdatasync.quartz;
|
||||
|
||||
import cn.hutool.log.Log;
|
||||
import com.seeyon.apps.common.config.ICstConfigApi;
|
||||
import com.seeyon.apps.ext.quartz.AbstractQuartzTask;
|
||||
import com.seeyon.apps.src_ydctdatasync.dao.FormExportUtil;
|
||||
import com.seeyon.apps.src_ydctdatasync.datamap.*;
|
||||
import com.seeyon.apps.src_ydctdatasync.datasource.DataSource;
|
||||
import com.seeyon.apps.src_ydctdatasync.utils.StatementQueryUtil;
|
||||
import com.seeyon.apps.src_ydctdatasync.utils.TimeUtils;
|
||||
import com.seeyon.ctp.common.AppContext;
|
||||
import com.seeyon.ctp.common.exceptions.BusinessException;
|
||||
import com.seeyon.ctp.services.ServiceException;
|
||||
import com.seeyon.ctp.util.JDBCAgent;
|
||||
import com.seeyon.v3x.services.form.FormFactory;
|
||||
import com.seeyon.v3x.services.form.bean.FormExport;
|
||||
import org.springframework.beans.factory.DisposableBean;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.SQLException;
|
||||
import java.text.DateFormat;
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.*;
|
||||
|
||||
public class YdzbDataSyncQuartz extends AbstractQuartzTask implements DisposableBean {
|
||||
|
||||
private static Log log = Log.get(YdzbDataSyncQuartz.class);
|
||||
protected ICstConfigApi cstConfigApi = (ICstConfigApi) AppContext.getBean("cstConfigApi");
|
||||
private FormFactory formFactory;
|
||||
private DataSource ydzbThirdDataSource = (DataSource) AppContext.getBean("ydzbThirdDataSource");
|
||||
private JDBCAgent agent = new JDBCAgent();
|
||||
private String zcTable;
|
||||
private String zcFormNo;
|
||||
private String contractTable;
|
||||
private String contractFormNo;
|
||||
private String feeFormNo;
|
||||
private String loginName;
|
||||
|
||||
public String getZcTable() {
|
||||
return zcTable;
|
||||
}
|
||||
|
||||
public void setZcTable(String zcTable) {
|
||||
this.zcTable = zcTable;
|
||||
}
|
||||
|
||||
public String getZcFormNo() {
|
||||
return zcFormNo;
|
||||
}
|
||||
|
||||
public void setZcFormNo(String zcFormNo) {
|
||||
this.zcFormNo = zcFormNo;
|
||||
}
|
||||
|
||||
public String getContractTable() {
|
||||
return contractTable;
|
||||
}
|
||||
|
||||
public void setContractTable(String contractTable) {
|
||||
this.contractTable = contractTable;
|
||||
}
|
||||
|
||||
public String getContractFormNo() {
|
||||
return contractFormNo;
|
||||
}
|
||||
|
||||
public void setContractFormNo(String contractFormNo) {
|
||||
this.contractFormNo = contractFormNo;
|
||||
}
|
||||
|
||||
public String getFeeFormNo() {
|
||||
return feeFormNo;
|
||||
}
|
||||
|
||||
public void setFeeFormNo(String feeFormNo) {
|
||||
this.feeFormNo = feeFormNo;
|
||||
}
|
||||
|
||||
public String getLoginName() {
|
||||
return loginName;
|
||||
}
|
||||
|
||||
public void setLoginName(String loginName) {
|
||||
this.loginName = loginName;
|
||||
}
|
||||
|
||||
public FormFactory getFormFactory() {
|
||||
if (formFactory == null) {
|
||||
formFactory = (FormFactory) AppContext.getBean("formFactory");
|
||||
}
|
||||
return formFactory;
|
||||
}
|
||||
|
||||
public void setFormFactory(FormFactory formFactory) {
|
||||
this.formFactory = formFactory;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "宜都城投资产数据同步任务";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String taskRun(String arg0) {
|
||||
log.info("宜都城投资产数据同步任务任务开始");
|
||||
long startTime = System.currentTimeMillis();
|
||||
try (Connection connection = ydzbThirdDataSource.getConnection()){
|
||||
processZcData(connection);
|
||||
processContractData(connection);
|
||||
DateFormat df = new SimpleDateFormat("yyyy-MM-dd");
|
||||
if (!arg0.equals("-1")) {
|
||||
try {
|
||||
Date date = df.parse(arg0);
|
||||
processFeeData(connection, date);
|
||||
}catch (ParseException e) {
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("宜都城投资产数据同步任务执行失败");
|
||||
log.error(e.getMessage(),e);
|
||||
}
|
||||
log.info("宜都城投资产数据同步任务任务结束,耗时:"+ (System.currentTimeMillis() - startTime)+ " ms");
|
||||
return null;
|
||||
}
|
||||
|
||||
//处理合同数据
|
||||
private void processContractData(Connection connection) throws SQLException, BusinessException, ServiceException {
|
||||
log.info("开始同步合同表数据");
|
||||
String countQuerySql = "SELECT count(*) FROM zb_contract;";
|
||||
String pageQuerySql = "SELECT * FROM zzb_contract limit 100 OFFSET ?;";
|
||||
ContractMode contractMode = new ContractMode();
|
||||
contractMode.setAgent(agent);
|
||||
long count = StatementQueryUtil.queryCount(countQuerySql,connection, null);
|
||||
int totalPage = (int)Math.ceil((double)count / 100);
|
||||
for(int i = 0; i < totalPage;i++) {
|
||||
List<Map<String, Object>> contractDataList = StatementQueryUtil.queryList(pageQuerySql, connection, i*100);
|
||||
for (Map<String, Object> rowMap : contractDataList) {
|
||||
Map<String, Object> targetMap = new HashMap<>();
|
||||
contractMode.preProcess(rowMap);
|
||||
contractMode.transfer(targetMap,rowMap);
|
||||
Map<String,Object> subMap = (Map<String,Object>)targetMap.get("subTable");
|
||||
targetMap.remove("subTable");
|
||||
upsertData(contractFormNo,convert2StringValue(targetMap),contractTable,convert2StringValue(subMap),"","");
|
||||
}
|
||||
}
|
||||
log.info("合同表数据同步结束");
|
||||
}
|
||||
|
||||
//处理费用数据
|
||||
private void processFeeData(Connection connection,Date date) throws SQLException, BusinessException, ServiceException {
|
||||
Date startDate = null;
|
||||
Date endDate = null;
|
||||
if(date == null) {
|
||||
startDate = TimeUtils.startOfYesterday();
|
||||
endDate = TimeUtils.startOf(new Date());
|
||||
}else {
|
||||
startDate = TimeUtils.startOf(TimeUtils.before(date,1));
|
||||
endDate = TimeUtils.startOf(date);
|
||||
}
|
||||
log.info("开始同步费用数据");
|
||||
processContractBillData(connection,startDate,endDate);
|
||||
processRefundData(connection,startDate,endDate);
|
||||
processHydpowerRechargeData(connection,startDate,endDate);
|
||||
log.info("费用数据同步结束");
|
||||
}
|
||||
|
||||
//处理合同费用
|
||||
private void processContractBillData(Connection connection,Date startDate,Date endDate) throws SQLException, BusinessException, ServiceException {
|
||||
log.info("开始同步合同费用数据");
|
||||
String countQuerySql = "SELECT count(*) FROM zb_contract_bill where;";
|
||||
String pageQuerySql = "SELECT * FROM zb_contract_bill where limit 100 OFFSET ?;";
|
||||
ContractBillMode contractBillMode = new ContractBillMode();
|
||||
contractBillMode.setAgent(agent);
|
||||
long count = StatementQueryUtil.queryCount(countQuerySql,connection,null);
|
||||
int totalPage = (int)Math.ceil((double)count / 100);
|
||||
for(int i = 0; i < totalPage;i++) {
|
||||
List<Map<String, Object>> gztdDataList = StatementQueryUtil.queryList(pageQuerySql, connection, i*100);
|
||||
for (Map<String, Object> rowMap : gztdDataList) {
|
||||
Map<String, Object> targetMap = new HashMap<>();
|
||||
contractBillMode.preProcess(rowMap);
|
||||
contractBillMode.transfer(targetMap,rowMap);
|
||||
|
||||
}
|
||||
}
|
||||
log.info("合同费用数据同步完成");
|
||||
}
|
||||
|
||||
private Map<String,String> convert2StringValue(Map<String,Object> oriMap) {
|
||||
Map<String,String> resMap = new HashMap<>();
|
||||
for (String key : oriMap.keySet()) {
|
||||
resMap.put(key,oriMap.get(key)+"");
|
||||
}
|
||||
return resMap;
|
||||
}
|
||||
|
||||
//处理水电费
|
||||
private void processHydpowerRechargeData(Connection connection,Date startDate,Date endDate) throws SQLException, BusinessException, ServiceException {
|
||||
log.info("开始同步水电费数据");
|
||||
String countQuerySql = "SELECT count(*) FROM zb_hydropower_recharge where recharge_time >= ? and recharge_time <=;";
|
||||
String pageQuerySql = "SELECT * FROM zb_hydropower_recharge where recharge_time >= ? and recharge_time <= ? limit 100 OFFSET ?;";
|
||||
HydropowerRechargeDataMapMode rechargeDataMapMode = new HydropowerRechargeDataMapMode();
|
||||
rechargeDataMapMode.setAgent(agent);
|
||||
long count = StatementQueryUtil.queryCount(countQuerySql,connection, startDate,endDate);
|
||||
int totalPage = (int)Math.ceil((double)count / 100);
|
||||
for(int i = 0; i < totalPage;i++) {
|
||||
List<Map<String, Object>> dataList = StatementQueryUtil.queryList(pageQuerySql, connection, startDate,endDate,i*100);
|
||||
for (Map<String, Object> rowMap : dataList) {
|
||||
Map<String, Object> targetMap = new HashMap<>();
|
||||
rechargeDataMapMode.preProcess(rowMap);
|
||||
rechargeDataMapMode.transfer(targetMap,rowMap);
|
||||
insertData(feeFormNo,convert2StringValue(targetMap));
|
||||
}
|
||||
}
|
||||
log.info("水电费数据同步完成");
|
||||
}
|
||||
|
||||
//处理退费
|
||||
private void processRefundData(Connection connection,Date startDate,Date endDate) throws SQLException, BusinessException, ServiceException {
|
||||
log.info("开始同步退费数据");
|
||||
String countQuerySql = "SELECT count(*) FROM zb_refund where create_time >= ? and create_time <= ?;";
|
||||
String pageQuerySql = "SELECT * FROM zb_contract_bill where create_time >= ? and create_time <= ? limit 100 OFFSET ?;";
|
||||
RefundDataMapMode refundDataMapMode = new RefundDataMapMode();
|
||||
refundDataMapMode.setAgent(agent);
|
||||
long count = StatementQueryUtil.queryCount(countQuerySql,connection, startDate,endDate);
|
||||
int totalPage = (int)Math.ceil((double)count / 100);
|
||||
for(int i = 0; i < totalPage;i++) {
|
||||
List<Map<String, Object>> dataList = StatementQueryUtil.queryList(pageQuerySql,connection, startDate,endDate,i*100);
|
||||
for (Map<String, Object> rowMap : dataList) {
|
||||
Map<String, Object> targetMap = new HashMap<>();
|
||||
refundDataMapMode.preProcess(rowMap);
|
||||
refundDataMapMode.transfer(targetMap,rowMap);
|
||||
insertData(feeFormNo,convert2StringValue(targetMap));
|
||||
}
|
||||
}
|
||||
log.info("退费数据同步结束");
|
||||
}
|
||||
|
||||
//处理资产数据
|
||||
private void processZcData(Connection connection) throws SQLException, BusinessException, ServiceException {
|
||||
log.info("开始同步资产表数据");
|
||||
processBzfHouseData(connection);
|
||||
processGzcfData(connection);
|
||||
processGzfwData(connection);
|
||||
processGztdData(connection);
|
||||
log.info("资产表数据同步结束");
|
||||
}
|
||||
|
||||
private void processGztdData(Connection connection) throws SQLException, BusinessException, ServiceException {
|
||||
log.info("开始同步国资土地数据");
|
||||
String countQuerySql = "SELECT count(*) FROM zb_gztd_house;";
|
||||
String pageQuerySql = "SELECT * FROM zb_gztd_house limit 100 OFFSET ?;";
|
||||
GztdAssetMode gztdAssetMode = new GztdAssetMode();
|
||||
gztdAssetMode.setAgent(agent);
|
||||
long count = StatementQueryUtil.queryCount(countQuerySql,connection, null);
|
||||
int totalPage = (int)Math.ceil((double)count / 100);
|
||||
for(int i = 0; i < totalPage;i++) {
|
||||
List<Map<String, Object>> dataList = StatementQueryUtil.queryList(pageQuerySql, connection, i*100);
|
||||
for (Map<String, Object> rowMap : dataList) {
|
||||
Map<String, Object> targetMap = new HashMap<>();
|
||||
gztdAssetMode.preProcess(rowMap);
|
||||
gztdAssetMode.transfer(targetMap,rowMap);
|
||||
upsertData(zcFormNo,convert2StringValue(targetMap),zcTable,"WHERE field0031 = ?",targetMap.get("资产编号") +"");
|
||||
}
|
||||
}
|
||||
log.info("国资土地数据同步完成");
|
||||
}
|
||||
|
||||
private void processGzfwData(Connection connection) throws SQLException, BusinessException, ServiceException {
|
||||
log.info("开始同步国资房屋数据");
|
||||
String countQuerySql = "SELECT count(*) FROM zb_gzfw_house;";
|
||||
String pageQuerySql = "SELECT * FROM zb_gzfw_house limit 100 OFFSET ?;";
|
||||
GzfwAssetMode gzfwAssetMode = new GzfwAssetMode();
|
||||
gzfwAssetMode.setAgent(agent);
|
||||
long count = StatementQueryUtil.queryCount(countQuerySql,connection, null);
|
||||
int totalPage = (int)Math.ceil((double)count / 100);
|
||||
for(int i = 0; i < totalPage;i++) {
|
||||
List<Map<String, Object>> dataList = StatementQueryUtil.queryList(pageQuerySql, connection, i*100);
|
||||
for (Map<String, Object> rowMap : dataList) {
|
||||
Map<String, Object> targetMap = new HashMap<>();
|
||||
gzfwAssetMode.preProcess(rowMap);
|
||||
gzfwAssetMode.transfer(targetMap,rowMap);
|
||||
upsertData(zcFormNo,convert2StringValue(targetMap),zcTable,"WHERE field0031 = ?",targetMap.get("资产编号") + "");
|
||||
}
|
||||
}
|
||||
log.info("国资房屋数据同步结束");
|
||||
}
|
||||
|
||||
private void processGzcfData(Connection connection) throws SQLException, BusinessException, ServiceException {
|
||||
log.info("开始同步国资厂房数据");
|
||||
String countQuerySql = "SELECT count(*) FROM zb_gzcf_house;";
|
||||
String pageQuerySql = "SELECT * FROM zb_gzcf_house limit 100 OFFSET ?;";
|
||||
GzcfAssetMode gzcfAssetMode = new GzcfAssetMode();
|
||||
gzcfAssetMode.setAgent(agent);
|
||||
long count = StatementQueryUtil.queryCount(countQuerySql,connection, null);
|
||||
int totalPage = (int)Math.ceil((double)count / 100);
|
||||
for(int i = 0; i < totalPage;i++) {
|
||||
List<Map<String, Object>> dataList = StatementQueryUtil.queryList(pageQuerySql, connection, i*100);
|
||||
for (Map<String, Object> rowMap : dataList) {
|
||||
Map<String, Object> targetMap = new HashMap<>();
|
||||
gzcfAssetMode.preProcess(rowMap);
|
||||
gzcfAssetMode.transfer(targetMap,rowMap);
|
||||
upsertData(zcFormNo,convert2StringValue(targetMap),getZcTable(),"WHERE field0031 = ?",targetMap.get("资产编号") + "");
|
||||
}
|
||||
}
|
||||
log.info("国资厂房数据同步完成");
|
||||
}
|
||||
|
||||
private void processBzfHouseData(Connection connection) throws SQLException, BusinessException, ServiceException {
|
||||
log.info("开始同步保障房数据");
|
||||
String countQuerySql = "SELECT count(*) FROM zb_bzf_house;";
|
||||
String pageQuerySql = "SELECT * FROM zb_bzf_house limit 100 OFFSET ?;";
|
||||
BzfAssetMode bzfAssetMode = new BzfAssetMode();
|
||||
bzfAssetMode.setAgent(agent);
|
||||
long count = StatementQueryUtil.queryCount(countQuerySql,connection, null);
|
||||
int totalPage = (int)Math.ceil((double)count / 100);
|
||||
for(int i = 0; i < totalPage;i++) {
|
||||
List<Map<String, Object>> dataList = StatementQueryUtil.queryList(pageQuerySql, connection, i*100);
|
||||
for (Map<String, Object> rowMap : dataList) {
|
||||
Map<String, Object> targetMap = new HashMap<>();
|
||||
rowMap.put("loginName",loginName);
|
||||
bzfAssetMode.preProcess(rowMap);
|
||||
bzfAssetMode.transfer(targetMap,rowMap);
|
||||
upsertData(zcFormNo,convert2StringValue(targetMap),zcTable,"WHERE field0031 = ?",targetMap.get("资产编号") + "");
|
||||
}
|
||||
}
|
||||
log.info("保障房数据同步结束");
|
||||
}
|
||||
|
||||
private void upsertData(String formNo,Map<String, String> targetMap,String table,String whereSql,String param) throws BusinessException, SQLException, ServiceException {
|
||||
//不存在则插入,存在则更新
|
||||
List<String> params = new ArrayList<>();
|
||||
params.add(param);
|
||||
String querySql = "SELECT * FROM " + table + whereSql +";";
|
||||
Map<String,Object> existData = null;
|
||||
try {
|
||||
//agent.execute(querySql,params);
|
||||
existData = agent.resultSetToMap();
|
||||
} catch (Exception e) {
|
||||
|
||||
}
|
||||
if(existData != null && existData.size() > 0) {
|
||||
for (String key : targetMap.keySet()) {
|
||||
existData.put(key,targetMap.get(key)+"");
|
||||
Map<String, Object> updateSqlMap = generateUpdateSql(existData, table, whereSql, param);
|
||||
agent.execute((String) updateSqlMap.get("sql"),updateSqlMap.get("params"));
|
||||
}
|
||||
}else {
|
||||
FormExport formExport = new FormExport();
|
||||
formExport.setValues(FormExportUtil.setFormValue(targetMap));
|
||||
getFormFactory().importBusinessFormData(loginName, formNo,formExport, new String[] {});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void insertData(String formNo,Map<String, String> targetMap) throws BusinessException, SQLException, ServiceException {
|
||||
FormExport formExport = new FormExport();
|
||||
formExport.setValues(FormExportUtil.setFormValue(targetMap));
|
||||
getFormFactory().importBusinessFormData(loginName, formNo,formExport, new String[] {});
|
||||
}
|
||||
|
||||
private void upsertData(String formNo,Map<String, String> targetMap,String table,Map<String, String> subTableMap,String whereSql,String param) throws BusinessException, SQLException, ServiceException {
|
||||
//不存在则插入,存在则更新
|
||||
List<String> params = new ArrayList<>();
|
||||
params.add(param);
|
||||
String querySql = "SELECT * FROM " + table + whereSql +";";
|
||||
Map<String,Object> existData = null;
|
||||
try {
|
||||
agent.execute(querySql,params);
|
||||
existData = agent.resultSetToMap();
|
||||
} catch (Exception e) {
|
||||
|
||||
}
|
||||
if(existData != null && existData.size() > 0) {
|
||||
for (String key : targetMap.keySet()) {
|
||||
existData.put(key,targetMap.get(key)+"");
|
||||
Map<String, Object> updateSqlMap = generateUpdateSql(existData, table, whereSql, param);
|
||||
agent.execute((String) updateSqlMap.get("sql"),updateSqlMap.get("params"));
|
||||
}
|
||||
}else {
|
||||
FormExport formExport = new FormExport();
|
||||
formExport.setValues(FormExportUtil.setFormValue(targetMap));
|
||||
formExport.setSubordinateForms(FormExportUtil.setSubordinateFormValue(subTableMap));
|
||||
getFormFactory().importBusinessFormData(loginName, formNo,formExport, new String[] {});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private Map<String, Object> generateUpdateSql(Map<String, Object> fieldValues, String tableName, String whereClause,String clauseValue) {
|
||||
if (fieldValues == null || fieldValues.isEmpty()) {
|
||||
throw new IllegalArgumentException("Field values cannot be null or empty");
|
||||
}
|
||||
if (tableName == null || tableName.trim().isEmpty()) {
|
||||
throw new IllegalArgumentException("Table name cannot be null or empty");
|
||||
}
|
||||
if (whereClause == null || whereClause.trim().isEmpty()) {
|
||||
throw new IllegalArgumentException("Where clause cannot be null or empty");
|
||||
}
|
||||
StringBuilder sqlBuilder = new StringBuilder("UPDATE ").append(tableName).append(" SET ");
|
||||
List<Object> params = new ArrayList<>();
|
||||
// Build the SET clause
|
||||
int fieldCount = 0;
|
||||
for (Map.Entry<String, Object> entry : fieldValues.entrySet()) {
|
||||
if (fieldCount > 0) {
|
||||
sqlBuilder.append(", ");
|
||||
}
|
||||
sqlBuilder.append(entry.getKey()).append(" = ?");
|
||||
params.add(entry.getValue());
|
||||
fieldCount++;
|
||||
}
|
||||
params.add(clauseValue);
|
||||
// Append the WHERE clause
|
||||
sqlBuilder.append(whereClause);
|
||||
// Create result map
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
result.put("sql", sqlBuilder.toString());
|
||||
result.put("params", params);
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void destroy() throws Exception {
|
||||
ydzbThirdDataSource.close();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
package com.seeyon.apps.src_ydctdatasync.utils;
|
||||
|
||||
import com.seeyon.ctp.common.AppContext;
|
||||
import com.seeyon.ctp.services.ServiceException;
|
||||
import com.seeyon.v3x.services.form.FormFactory;
|
||||
import com.seeyon.v3x.services.form.bean.FormExport;
|
||||
|
||||
public class DataInsertWithFormUtils {
|
||||
private FormFactory formFactory;
|
||||
|
||||
public FormFactory getFormFactory() {
|
||||
if (formFactory == null) {
|
||||
formFactory = (FormFactory) AppContext.getBean("formFactory");
|
||||
}
|
||||
return formFactory;
|
||||
}
|
||||
|
||||
public void setFormFactory(FormFactory formFactory) {
|
||||
this.formFactory = formFactory;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param loginName 登录名
|
||||
* @param formNo 表单模板编号
|
||||
* @param formExport 要插入的表单数据
|
||||
*/
|
||||
public void dataInsert(String loginName , String formNo , FormExport formExport) {
|
||||
try {
|
||||
getFormFactory().importBusinessFormData(loginName, formNo,
|
||||
formExport, new String[] {});
|
||||
} catch (ServiceException e) {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
package com.seeyon.apps.src_ydctdatasync.utils;
|
||||
|
||||
import com.seeyon.ctp.common.AppContext;
|
||||
import com.seeyon.ctp.common.ctpenumnew.manager.EnumManager;
|
||||
import com.seeyon.ctp.common.po.ctpenumnew.CtpEnumBean;
|
||||
import com.seeyon.ctp.common.po.ctpenumnew.CtpEnumItem;
|
||||
import com.seeyon.ctp.util.JDBCAgent;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class EnumMapUtils {
|
||||
public static String getEnumItemValue(JDBCAgent agent,String groupValue,String targetValue) {
|
||||
String queryIdSql = "SELECT ID FROM ctp_enum WHERE `ENUMNAME` = ?";
|
||||
Long enumId = null;
|
||||
try {
|
||||
agent.execute(queryIdSql,groupValue);
|
||||
Map map = agent.resultSetToMap();
|
||||
enumId = (Long)map.get("id");
|
||||
} catch (Exception e) {
|
||||
return null;
|
||||
}
|
||||
EnumManager enumManagerNew = (EnumManager) AppContext.getBean("enumManagerNew");
|
||||
CtpEnumBean ctpEnumBean = enumManagerNew.getEnum(enumId);
|
||||
if(ctpEnumBean == null) {
|
||||
return "";
|
||||
}
|
||||
List<CtpEnumItem> ctpEnumItems = ctpEnumBean.getItems();
|
||||
if(ctpEnumBean.getItems() == null) {
|
||||
return null;
|
||||
}
|
||||
for (CtpEnumItem enumItem : ctpEnumItems) {
|
||||
if(enumItem.getShowvalue().equals(targetValue)) {
|
||||
return enumItem.getValue();
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,102 @@
|
||||
package com.seeyon.apps.src_ydctdatasync.utils;
|
||||
|
||||
import java.sql.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class StatementQueryUtil {
|
||||
|
||||
/**
|
||||
* 执行查询语句并将结果转换为 List<Map<String, Object>>
|
||||
* @param sql 查询语句
|
||||
* @param params 查询参数
|
||||
* @return 查询结果列表
|
||||
* @throws SQLException 数据库操作异常
|
||||
*/
|
||||
public static List<Map<String, Object>> queryList(String sql,Connection connection,Object ...params) throws SQLException {
|
||||
List<Map<String, Object>> resultList = new ArrayList<>();
|
||||
try (PreparedStatement preparedStatement = connection.prepareStatement(sql)) {
|
||||
// 设置参数
|
||||
for (int i = 0; params != null && i < params.length; i++) {
|
||||
preparedStatement.setObject(i + 1, params[i]);
|
||||
}
|
||||
|
||||
// 执行查询
|
||||
try (ResultSet resultSet = preparedStatement.executeQuery()) {
|
||||
// 获取元数据
|
||||
ResultSetMetaData metaData = resultSet.getMetaData();
|
||||
int columnCount = metaData.getColumnCount();
|
||||
|
||||
// 遍历结果集
|
||||
while (resultSet.next()) {
|
||||
Map<String, Object> rowMap = new HashMap<>();
|
||||
for (int i = 1; i <= columnCount; i++) {
|
||||
String columnName = metaData.getColumnLabel(i);
|
||||
Object columnValue = resultSet.getObject(i);
|
||||
rowMap.put(columnName, columnValue);
|
||||
}
|
||||
resultList.add(rowMap);
|
||||
}
|
||||
}
|
||||
}
|
||||
return resultList;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param sql 查询语句
|
||||
* @param params 查询参数
|
||||
* @return 查询结果列表
|
||||
* @throws SQLException 数据库操作异常
|
||||
*/
|
||||
public static Map<String, Object> querySingle(String sql,Connection connection,Object ...params) throws SQLException {
|
||||
Map<String,Object> resMap = new HashMap<>();
|
||||
try (PreparedStatement preparedStatement = connection.prepareStatement(sql)) {
|
||||
// 设置参数
|
||||
for (int i = 0; params != null && i < params.length; i++) {
|
||||
preparedStatement.setObject(i + 1, params[i]);
|
||||
}
|
||||
|
||||
// 执行查询
|
||||
try (ResultSet resultSet = preparedStatement.executeQuery()) {
|
||||
// 获取元数据
|
||||
ResultSetMetaData metaData = resultSet.getMetaData();
|
||||
// 填充结果
|
||||
if(!resultSet.next()) {
|
||||
return resMap;
|
||||
}
|
||||
String columnName = metaData.getColumnLabel(0);
|
||||
Object columnValue = resultSet.getObject(0);
|
||||
resMap.put(columnName, columnValue);
|
||||
}
|
||||
}
|
||||
return resMap;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param sql 查询语句
|
||||
* @param params 查询参数
|
||||
* @return 查询结果条数
|
||||
* @throws SQLException 数据库操作异常
|
||||
*/
|
||||
public static long queryCount(String sql, Connection connection,Object... params) throws SQLException {
|
||||
long count = 0;
|
||||
try (PreparedStatement preparedStatement = connection.prepareStatement(sql)) {
|
||||
// 设置参数
|
||||
for (int i = 0; params != null && i < params.length; i++) {
|
||||
preparedStatement.setObject(i + 1, params[i]);
|
||||
}
|
||||
|
||||
// 执行查询
|
||||
try (ResultSet resultSet = preparedStatement.executeQuery()) {
|
||||
if (resultSet.next()) {
|
||||
count = resultSet.getLong(1); // 获取第一列的值
|
||||
}
|
||||
}
|
||||
}
|
||||
return count;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,533 @@
|
||||
package com.seeyon.apps.src_ydctdatasync.utils;
|
||||
|
||||
import java.text.DateFormat;
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.TimeZone;
|
||||
|
||||
public class TimeUtils {
|
||||
public static final String DEFAULT_PATTERN = "yyyy-MM-dd";
|
||||
|
||||
public static String format(Date date) {
|
||||
return format(date, DEFAULT_PATTERN);
|
||||
}
|
||||
|
||||
public static String format(Date date, String pattern) {
|
||||
if (date == null) {
|
||||
return "";
|
||||
}
|
||||
DateFormat dateFormat = new SimpleDateFormat(pattern);
|
||||
return dateFormat.format(date);
|
||||
}
|
||||
|
||||
/**
|
||||
* UTC时间转换为本地时间;待解析的字符串必须以yyyy-MM-dd格式开头
|
||||
*/
|
||||
public static Date utcParse(String utcTimeStr) throws ParseException {
|
||||
String utcTimePattern = "yyyy-MM-dd";
|
||||
String subTime = utcTimeStr.substring(10);// UTC时间格式以 yyyy-MM-dd 开头,将utc时间的前10位截取掉,之后是含有多时区时间格式信息的数据
|
||||
// 处理当后缀为:+8:00时,转换为:+08:00 或 -8:00转换为-08:00
|
||||
if (subTime.indexOf("+") != -1) {
|
||||
subTime = changeUtcSuffix(subTime, "+");
|
||||
}
|
||||
if (subTime.indexOf("-") != -1) {
|
||||
subTime = changeUtcSuffix(subTime, "-");
|
||||
}
|
||||
utcTimeStr = utcTimeStr.substring(0, 10) + subTime;
|
||||
// 依据传入函数的utc时间,得到对应的utc时间格式
|
||||
// 步骤一:处理 T
|
||||
if (utcTimeStr.indexOf("T") != -1) {
|
||||
utcTimePattern = utcTimePattern + "'T'";
|
||||
}
|
||||
// 兼容yyyy-MM-dd的格式,这种格式不需要加空格
|
||||
if(utcTimeStr.indexOf("T") == -1 && subTime.length() > 0) {
|
||||
utcTimePattern = utcTimePattern + " ";
|
||||
}
|
||||
// 步骤二:处理毫秒SSS
|
||||
if (utcTimeStr.indexOf(".") != -1) {
|
||||
utcTimePattern = utcTimePattern + "HH:mm:ss.SSS";
|
||||
} else if (utcTimeStr.indexOf(":") != -1) {
|
||||
utcTimePattern = utcTimePattern + "HH:mm:ss";
|
||||
}
|
||||
// 步骤三:处理时区问题
|
||||
if (subTime.indexOf("+") != -1 || subTime.indexOf("-") != -1) {
|
||||
utcTimePattern = utcTimePattern + "XXX";
|
||||
} else if (subTime.indexOf("Z") != -1) {
|
||||
utcTimePattern = utcTimePattern + "'Z'";
|
||||
}
|
||||
DateFormat dateFormat = new SimpleDateFormat(utcTimePattern);
|
||||
if (subTime.indexOf("Z") != -1) {
|
||||
dateFormat.setTimeZone(TimeZone.getTimeZone("UTC"));
|
||||
}
|
||||
return dateFormat.parse(utcTimeStr);
|
||||
}
|
||||
|
||||
private static String changeUtcSuffix(String subTime, String sign) {
|
||||
String timeSuffix = null;
|
||||
String[] splitTimeArrayOne = subTime.split("\\\\" + sign);
|
||||
String[] splitTimeArrayTwo = splitTimeArrayOne[1].split(":");
|
||||
if (splitTimeArrayTwo[0].length() < 2) {
|
||||
timeSuffix = "+" + "0" + splitTimeArrayTwo[0] + ":" + splitTimeArrayTwo[1];
|
||||
subTime = splitTimeArrayOne[0] + timeSuffix;
|
||||
return subTime;
|
||||
}
|
||||
return subTime;
|
||||
}
|
||||
|
||||
/**
|
||||
* 所在周的开始
|
||||
* @param date
|
||||
* @return
|
||||
*/
|
||||
public static Date startOfWeek(Date date) {
|
||||
if (date == null) {
|
||||
return null;
|
||||
}
|
||||
Calendar c = Calendar.getInstance();
|
||||
c.setTime(date);
|
||||
c.setFirstDayOfWeek(Calendar.MONDAY);
|
||||
c.set(Calendar.DAY_OF_WEEK, Calendar.MONDAY);
|
||||
c.set(Calendar.HOUR_OF_DAY, 0);
|
||||
c.set(Calendar.MINUTE, 0);
|
||||
c.set(Calendar.SECOND, 0);
|
||||
return c.getTime();
|
||||
}
|
||||
|
||||
/**
|
||||
* 所在周的结束
|
||||
* @param date
|
||||
* @return
|
||||
*/
|
||||
public static Date endOfWeek(Date date) {
|
||||
if (date == null) {
|
||||
return null;
|
||||
}
|
||||
Calendar c = Calendar.getInstance();
|
||||
c.setTime(date);
|
||||
c.setFirstDayOfWeek(Calendar.MONDAY);
|
||||
c.set(Calendar.DAY_OF_WEEK, Calendar.SUNDAY);
|
||||
c.set(Calendar.HOUR_OF_DAY, 23);
|
||||
c.set(Calendar.MINUTE, 59);
|
||||
c.set(Calendar.SECOND, 59);
|
||||
return c.getTime();
|
||||
}
|
||||
|
||||
/**
|
||||
* 所在月的开始
|
||||
* @param date
|
||||
* @return
|
||||
*/
|
||||
public static Date startOfMonth(Date date) {
|
||||
if (date == null) {
|
||||
return null;
|
||||
}
|
||||
Calendar c = Calendar.getInstance();
|
||||
c.setTime(date);
|
||||
c.set(Calendar.DAY_OF_MONTH, 1);
|
||||
c.set(Calendar.HOUR_OF_DAY, 0);
|
||||
c.set(Calendar.MINUTE, 0);
|
||||
c.set(Calendar.SECOND, 0);
|
||||
c.set(Calendar.MILLISECOND, c.getMinimum(Calendar.MILLISECOND));
|
||||
return c.getTime();
|
||||
}
|
||||
|
||||
/**
|
||||
* 所在月的结束
|
||||
* @param date
|
||||
* @return
|
||||
*/
|
||||
public static Date endOfMonth(Date date) {
|
||||
if (date == null) {
|
||||
return null;
|
||||
}
|
||||
Calendar c = Calendar.getInstance();
|
||||
c.setTime(date);
|
||||
c.set(Calendar.DAY_OF_MONTH, c.getActualMaximum(Calendar.DAY_OF_MONTH));
|
||||
c.set(Calendar.HOUR_OF_DAY, 23);
|
||||
c.set(Calendar.MINUTE, 59);
|
||||
c.set(Calendar.SECOND, 59);
|
||||
return c.getTime();
|
||||
}
|
||||
|
||||
/**
|
||||
* 本月开始
|
||||
* @return
|
||||
*/
|
||||
public static Date startOfCurMonth() {
|
||||
return startOfMonth(new Date());
|
||||
}
|
||||
|
||||
/**
|
||||
* 本月结束
|
||||
* @return
|
||||
*/
|
||||
public static Date endOfCurMonth() {
|
||||
return endOfMonth(new Date());
|
||||
}
|
||||
|
||||
/**
|
||||
* 上月开始
|
||||
* @return
|
||||
*/
|
||||
public static Date startOfPreMonth() {
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
calendar.setTime(startOfCurMonth());
|
||||
calendar.add(Calendar.MONTH, -1);
|
||||
return calendar.getTime();
|
||||
}
|
||||
|
||||
/**
|
||||
* 上月结束
|
||||
* @return
|
||||
*/
|
||||
public static Date endOfPreMonth() {
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
calendar.add(Calendar.MONTH, -1);
|
||||
calendar.setTime(endOfMonth(calendar.getTime()));
|
||||
return calendar.getTime();
|
||||
}
|
||||
|
||||
/**
|
||||
* 本周开始
|
||||
* @return
|
||||
*/
|
||||
public static Date startOfCurWeek() {
|
||||
return startOfWeek(new Date());
|
||||
}
|
||||
|
||||
/**
|
||||
* 本周结束
|
||||
* @return
|
||||
*/
|
||||
public static Date endOfCurWeek() {
|
||||
return endOfWeek(new Date());
|
||||
}
|
||||
|
||||
/**
|
||||
* 上周开始
|
||||
* @return
|
||||
*/
|
||||
public static Date startOfPreWeek() {
|
||||
Date curMon = startOfCurWeek();
|
||||
Calendar c = Calendar.getInstance();
|
||||
c.setTime(curMon);
|
||||
c.add(Calendar.DAY_OF_WEEK, -7);
|
||||
return c.getTime();
|
||||
}
|
||||
|
||||
/**
|
||||
* 上周结束
|
||||
* @return
|
||||
*/
|
||||
public static Date endOfPreWeek() {
|
||||
Date curSun = endOfCurWeek();
|
||||
Calendar c = Calendar.getInstance();
|
||||
c.setTime(curSun);
|
||||
c.add(Calendar.DAY_OF_WEEK, -7);
|
||||
return c.getTime();
|
||||
}
|
||||
|
||||
/**
|
||||
* 一天的结束
|
||||
* @param date
|
||||
* @return
|
||||
*/
|
||||
public static Date endOf(Date date) {
|
||||
if (date == null) {
|
||||
return null;
|
||||
}
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
calendar.setTime(date);
|
||||
calendar.set(Calendar.HOUR_OF_DAY, 23);
|
||||
calendar.set(Calendar.MINUTE, 59);
|
||||
calendar.set(Calendar.SECOND, 59);
|
||||
return calendar.getTime();
|
||||
}
|
||||
|
||||
/**
|
||||
* 一天的开始
|
||||
* @param date
|
||||
* @return
|
||||
*/
|
||||
public static Date startOf(Date date) {
|
||||
if (date == null) {
|
||||
return null;
|
||||
}
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
calendar.setTime(date);
|
||||
calendar.set(Calendar.HOUR_OF_DAY, 0);
|
||||
calendar.set(Calendar.MINUTE, 0);
|
||||
calendar.set(Calendar.SECOND, 0);
|
||||
calendar.set(Calendar.MILLISECOND,0);
|
||||
return calendar.getTime();
|
||||
}
|
||||
|
||||
/**
|
||||
* 昨天的开始
|
||||
* @return
|
||||
*/
|
||||
public static Date startOfYesterday() {
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
calendar.add(Calendar.DAY_OF_MONTH, -1);
|
||||
return startOf(calendar.getTime());
|
||||
}
|
||||
|
||||
/**
|
||||
* 昨天的结束
|
||||
* @return
|
||||
*/
|
||||
public static Date endOfYesterday() {
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
calendar.add(Calendar.DAY_OF_MONTH, -1);
|
||||
return endOf(calendar.getTime());
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取几天之后的日期
|
||||
*
|
||||
* @param date
|
||||
* @param after
|
||||
* @return
|
||||
*/
|
||||
public static Date after(Date date, int after) {
|
||||
if (date == null) {
|
||||
return null;
|
||||
}
|
||||
if (after <= 0) {
|
||||
return date;
|
||||
}
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
calendar.setTime(date);
|
||||
calendar.add(Calendar.DATE, after);
|
||||
return calendar.getTime();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取几年后的日期
|
||||
* @param date
|
||||
* @param year
|
||||
* @return
|
||||
*/
|
||||
public static Date afterYear(Date date, int year) {
|
||||
if(date == null) {
|
||||
return null;
|
||||
}
|
||||
if(year <= 0) {
|
||||
return date;
|
||||
}
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
calendar.setTime(date);
|
||||
calendar.add(Calendar.YEAR, year);
|
||||
return calendar.getTime();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取几天之前的日期
|
||||
*
|
||||
* @param date
|
||||
* @param before
|
||||
* @return
|
||||
*/
|
||||
public static Date before(Date date, int before) {
|
||||
if (date == null) {
|
||||
return null;
|
||||
}
|
||||
if (before <= 0) {
|
||||
return date;
|
||||
}
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
calendar.setTime(date);
|
||||
calendar.add(Calendar.DATE, -1 * before);
|
||||
return calendar.getTime();
|
||||
}
|
||||
|
||||
public static Date monthsAgo(Date date, int months) {
|
||||
Calendar ca = Calendar.getInstance();
|
||||
ca.setTime(date);
|
||||
ca.add(Calendar.MONTH, -months);
|
||||
return ca.getTime();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取几分钟之前的时间
|
||||
* @return
|
||||
*/
|
||||
public static Date minsAgo(Date date, int mins){
|
||||
Calendar ca = Calendar.getInstance();
|
||||
ca.setTime(date);
|
||||
ca.add(Calendar.MINUTE,-mins);
|
||||
return ca.getTime();
|
||||
}
|
||||
|
||||
public static Date startOfHour(Date date) {
|
||||
if (date == null) {
|
||||
return null;
|
||||
}
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
calendar.setTime(date);
|
||||
calendar.set(Calendar.MINUTE, 0);
|
||||
calendar.set(Calendar.SECOND, 0);
|
||||
return calendar.getTime();
|
||||
}
|
||||
|
||||
public static Date endOfHour(Date date) {
|
||||
if (date == null) {
|
||||
return null;
|
||||
}
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
calendar.setTime(date);
|
||||
calendar.set(Calendar.MINUTE, 59);
|
||||
calendar.set(Calendar.SECOND, 59);
|
||||
return calendar.getTime();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取两个时间相差的月数
|
||||
* @param date1
|
||||
* @param date2
|
||||
* @return
|
||||
*/
|
||||
public static int getMonthSpace(Date date1,Date date2)
|
||||
{
|
||||
int iMonth = 0;
|
||||
int flag = 0;
|
||||
try{
|
||||
Calendar objCalendarDate1 = Calendar.getInstance();
|
||||
objCalendarDate1.setTime(date1);
|
||||
|
||||
Calendar objCalendarDate2 = Calendar.getInstance();
|
||||
objCalendarDate2.setTime(date2);
|
||||
|
||||
if (objCalendarDate2.equals(objCalendarDate1)) {
|
||||
return 0;
|
||||
}
|
||||
if (objCalendarDate1.after(objCalendarDate2)){
|
||||
Calendar temp = objCalendarDate1;
|
||||
objCalendarDate1 = objCalendarDate2;
|
||||
objCalendarDate2 = temp;
|
||||
}
|
||||
if (objCalendarDate2.get(Calendar.DAY_OF_MONTH) < objCalendarDate1.get(Calendar.DAY_OF_MONTH)) {
|
||||
flag = 1;
|
||||
}
|
||||
|
||||
if (objCalendarDate2.get(Calendar.YEAR) > objCalendarDate1.get(Calendar.YEAR)) {
|
||||
iMonth = ((objCalendarDate2.get(Calendar.YEAR) - objCalendarDate1.get(Calendar.YEAR))
|
||||
* 12 + objCalendarDate2.get(Calendar.MONTH) - flag)
|
||||
- objCalendarDate1.get(Calendar.MONTH);
|
||||
} else {
|
||||
iMonth = objCalendarDate2.get(Calendar.MONTH)
|
||||
- objCalendarDate1.get(Calendar.MONTH) - flag;
|
||||
}
|
||||
|
||||
} catch (Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
return iMonth;
|
||||
}
|
||||
|
||||
/**
|
||||
* 得到日期num个月时的日期
|
||||
* num为正数 为date后num个月
|
||||
* num为负数 为date前num个月
|
||||
* @param date
|
||||
* @param num
|
||||
* @return
|
||||
*/
|
||||
public static Date getDateOfMonth(Date date,int num){
|
||||
if(date == null){
|
||||
return null;
|
||||
}
|
||||
Calendar calendar = Calendar.getInstance(); //得到日历
|
||||
calendar.setTime(date); //把当前时间赋给日历
|
||||
calendar.add(Calendar.MONTH, num); //设置为前num月
|
||||
return calendar.getTime();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获得两个时间相差的天数
|
||||
* @param minDate
|
||||
* @param maxDate
|
||||
* @return
|
||||
*/
|
||||
public static int getDaySpace(Date minDate,Date maxDate){
|
||||
int days = (int) ((maxDate.getTime() - minDate.getTime()) / (1000*3600*24));
|
||||
return Math.abs(days);
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断两个时间是否是同一天
|
||||
*
|
||||
* @param d1
|
||||
* @param d2
|
||||
* @return
|
||||
*/
|
||||
public static boolean sameDay(Date d1, Date d2) {
|
||||
if (d1 == null || d2 == null) {
|
||||
return false;
|
||||
}
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
calendar.setTime(d1);
|
||||
int yearOfDate1 = calendar.get(Calendar.YEAR);
|
||||
int dayOfDate1 = calendar.get(Calendar.DAY_OF_YEAR);
|
||||
calendar.setTime(d2);
|
||||
int yearOfDate2 = calendar.get(Calendar.YEAR);
|
||||
int dayOfDate2 = calendar.get(Calendar.DAY_OF_YEAR);
|
||||
|
||||
return yearOfDate1 == yearOfDate2 && dayOfDate1 == dayOfDate2; // 年份和一年当中的天数相同
|
||||
}
|
||||
|
||||
public static Date preYear(Date date) {
|
||||
if (date == null) {
|
||||
return null;
|
||||
}
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
calendar.setTime(date);
|
||||
calendar.add(Calendar.YEAR, -1);
|
||||
return calendar.getTime();
|
||||
}
|
||||
|
||||
public static Date endOfPreYear(Date date) {
|
||||
if (date == null) {
|
||||
return null;
|
||||
}
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
calendar.setTime(date);
|
||||
calendar.add(Calendar.YEAR, -1);
|
||||
calendar.set(Calendar.MONTH, calendar.getActualMaximum(Calendar.MONTH));
|
||||
return endOfMonth(calendar.getTime());
|
||||
}
|
||||
|
||||
|
||||
public static Date endOfYear(Date date) {
|
||||
if (date == null) {
|
||||
return null;
|
||||
}
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
calendar.setTime(date);
|
||||
calendar.set(Calendar.MONTH, calendar.getActualMaximum(Calendar.MONTH));
|
||||
return endOfMonth(calendar.getTime());
|
||||
}
|
||||
|
||||
public static Date startOfYear(Date date) {
|
||||
if (date == null) {
|
||||
return null;
|
||||
}
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
calendar.setTime(date);
|
||||
calendar.set(Calendar.MONTH, calendar.getMinimum(Calendar.MONTH));
|
||||
return startOfMonth(calendar.getTime());
|
||||
}
|
||||
|
||||
public static Date nextMonth(Date date) {
|
||||
if (date == null) {
|
||||
return null;
|
||||
}
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
calendar.setTime(date);
|
||||
calendar.add(Calendar.MONTH, +1);
|
||||
return calendar.getTime();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<plugin>
|
||||
<id>src_ydctdatasync</id>
|
||||
<name>宜都城投数据同步</name>
|
||||
<category>20241231</category>
|
||||
</plugin>
|
||||
@@ -0,0 +1,13 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
|
||||
<beans default-autowire="byName">
|
||||
<bean id="ydzbDataSyncQuartz" class="com.seeyon.apps.src_ydctdatasync.quartz.YdzbDataSyncQuartz">
|
||||
<property name="zcTable" value="formmain_0013"/>
|
||||
<property name="zcFormNo" value="zcbd1"/>
|
||||
<property name="contractTable" value=""/>
|
||||
<property name="contractFormNo" value=""/>
|
||||
<property name="feeFormNo" value=""/>
|
||||
<property name="loginName" value="dev"/>
|
||||
</bean>
|
||||
|
||||
</beans>
|
||||
@@ -0,0 +1,15 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
|
||||
<beans default-autowire="byName">
|
||||
<bean id="ydzbdataSyncPluginApi" class="com.seeyon.apps.src_ydctdatasync.YdzbdataSyncPluginApi"/>
|
||||
<bean id="ydzbThirdDataSource" class="com.seeyon.apps.src_ydctdatasync.datasource.DataSource">
|
||||
<property name="config">
|
||||
<bean class="com.seeyon.apps.src_ydctdatasync.config.DataSourceConfig">
|
||||
<property name="driver" value="com.mysql.jdbc.Driver"/>
|
||||
<property name="url" value="jdbc:mysql://127.0.0.1:3306/ydzb_oa?serverTimezone=Asia/Shanghai&useSSL=false&allowPublicKeyRetrieval=true"/>
|
||||
<property name="username" value="root"/>
|
||||
<property name="password" value="123456"/>
|
||||
</bean>
|
||||
</property>
|
||||
</bean>
|
||||
</beans>
|
||||
Reference in New Issue
Block a user