新增U8主数据抽取
This commit is contained in:
parent
f7a458522b
commit
3dd4c5adaf
|
@ -926,6 +926,7 @@ where id = #{id}
|
||||||
USER_TAB_COLUMNS
|
USER_TAB_COLUMNS
|
||||||
WHERE
|
WHERE
|
||||||
TABLE_NAME = #{tableName}
|
TABLE_NAME = #{tableName}
|
||||||
|
and table_schema = 'businesscenter'
|
||||||
|
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
@ -934,6 +935,7 @@ where id = #{id}
|
||||||
SELECT LOWER(COLUMN_NAME)
|
SELECT LOWER(COLUMN_NAME)
|
||||||
FROM information_schema.columns
|
FROM information_schema.columns
|
||||||
WHERE table_name = #{tableName}
|
WHERE table_name = #{tableName}
|
||||||
|
and table_schema = 'businesscenter'
|
||||||
</select>
|
</select>
|
||||||
<!-- 分页查询列表 采用like格式 -->
|
<!-- 分页查询列表 采用like格式 -->
|
||||||
<select id="queryMdmST" resultType="com.alibaba.fastjson.JSONObject" parameterType="java.util.HashMap">
|
<select id="queryMdmST" resultType="com.alibaba.fastjson.JSONObject" parameterType="java.util.HashMap">
|
||||||
|
|
|
@ -415,7 +415,7 @@ FROM
|
||||||
INFORMATION_SCHEMA.COLUMNS
|
INFORMATION_SCHEMA.COLUMNS
|
||||||
WHERE
|
WHERE
|
||||||
TABLE_NAME = #{tableName}
|
TABLE_NAME = #{tableName}
|
||||||
and TABLE_SCHEMA = 'businesscenter'
|
table_schema = 'businesscenter'
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -100,14 +100,26 @@ public class MasterDataServiceImpl extends BaseService<ComparisonEntity, String>
|
||||||
case "5":
|
case "5":
|
||||||
//通过主数据编码判断,不同的接口走不通的查询逻辑
|
//通过主数据编码判断,不同的接口走不通的查询逻辑
|
||||||
switch (mdmCode){
|
switch (mdmCode){
|
||||||
case "10003"://致远用户信息
|
case "10011"://U8物料信息
|
||||||
tableName = "mdm_user";
|
tableName = "mdm_materiel";
|
||||||
listAll = bindingUser(jsonObject, mdmModuleSourceEntity, dbCode,startTime,endTime);
|
listAll = bindingU8Materiel(jsonObject, mdmModuleSourceEntity, dbCode,startTime,endTime);
|
||||||
|
break;
|
||||||
|
case "10013"://U8仓库信息
|
||||||
|
tableName = "mdm_warehouse";
|
||||||
|
listAll = bindingU8Warehouse(jsonObject, mdmModuleSourceEntity, dbCode,startTime,endTime);
|
||||||
|
break;
|
||||||
|
case "10004"://U8客户信息
|
||||||
|
tableName = "mdm_customer";
|
||||||
|
listAll = bindingU8Customer(jsonObject, mdmModuleSourceEntity, dbCode,startTime,endTime);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
logger.info("未匹配到主数据的编码,请检查");
|
logger.info("未匹配到主数据的编码,请检查");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
logger.info("未知系统,请检查");
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
//调用主数据接口进行数据推送或更新
|
//调用主数据接口进行数据推送或更新
|
||||||
if (null != listAll && listAll.size() > 0) {
|
if (null != listAll && listAll.size() > 0) {
|
||||||
|
@ -122,6 +134,114 @@ public class MasterDataServiceImpl extends BaseService<ComparisonEntity, String>
|
||||||
}
|
}
|
||||||
return BaseResult.getSuccessMessageEntity("主数据同步成功");
|
return BaseResult.getSuccessMessageEntity("主数据同步成功");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private List<JSONObject> bindingU8Customer(JSONObject jsonObject, MdmModuleSourceEntity mdmModuleSourceEntity, String dbCode, String startTime, String endTime) {
|
||||||
|
List<JSONObject> list = new ArrayList<>();
|
||||||
|
StringBuffer sb = new StringBuffer();
|
||||||
|
if(null != jsonObject && StrUtil.isNotEmpty(jsonObject.getString("code"))){
|
||||||
|
String code = jsonObject.getString("code");
|
||||||
|
sb.append(" and a.ccuscode = '"+code+"'");
|
||||||
|
}else{
|
||||||
|
// ts = DateUtil.dateToString(new Date(), "yyyy-MM-dd HH:mm:ss");
|
||||||
|
sb.append(" and a.dModifyDate >= '"+startTime+"'");
|
||||||
|
sb.append(" and a.dModifyDate <> '"+endTime+"'");
|
||||||
|
}
|
||||||
|
StringBuffer stringBuffer = new StringBuffer();
|
||||||
|
stringBuffer.append("select * from v_hzya_Customer a WHERE 1=1 " +sb.toString());
|
||||||
|
mdmModuleSourceEntity.setDataSourceCode(dbCode);
|
||||||
|
List<HashMap<String, Object>> hashMaps = masterDataDaoImpl.queryArchivesByDataSource(stringBuffer.toString(),mdmModuleSourceEntity);
|
||||||
|
if(CollectionUtils.isNotEmpty(hashMaps)){
|
||||||
|
for (HashMap<String, Object> hashMap : hashMaps) {
|
||||||
|
JSONObject main = new JSONObject();
|
||||||
|
JSONObject mdm_cust = new JSONObject();
|
||||||
|
for(String key:hashMap.keySet()) {
|
||||||
|
mdm_cust.put(key, hashMap.get(key));
|
||||||
|
}
|
||||||
|
//获取明细信息
|
||||||
|
String ccuscode = (String) hashMap.get("ccuscode");
|
||||||
|
StringBuffer stringBufferDetails = new StringBuffer();
|
||||||
|
stringBufferDetails.append("select * from v_hzya_CustomerBank WHERE cCusCode = '"+ccuscode+"' " );
|
||||||
|
List<HashMap<String, Object>> hashMapsDetails = masterDataDaoImpl.queryArchivesByDataSource(stringBufferDetails.toString(),mdmModuleSourceEntity);
|
||||||
|
JSONArray mdm_customer_bank = new JSONArray();
|
||||||
|
if(CollectionUtils.isNotEmpty(hashMapsDetails)){
|
||||||
|
for (HashMap<String, Object> detailsMap : hashMapsDetails) {
|
||||||
|
JSONObject details = new JSONObject();
|
||||||
|
for (String key : detailsMap.keySet()) {
|
||||||
|
details.put(key, detailsMap.get(key));
|
||||||
|
}
|
||||||
|
mdm_customer_bank.add(details);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
main.put("mdm_customer_bank",mdm_customer_bank);
|
||||||
|
main.put("mdm_customer",mdm_cust);
|
||||||
|
list.add(main);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<JSONObject> bindingU8Warehouse(JSONObject jsonObject, MdmModuleSourceEntity mdmModuleSourceEntity, String dbCode, String startTime, String endTime) {
|
||||||
|
List<JSONObject> list = new ArrayList<>();
|
||||||
|
StringBuffer sb = new StringBuffer();
|
||||||
|
if(null != jsonObject && StrUtil.isNotEmpty(jsonObject.getString("code"))){
|
||||||
|
String code = jsonObject.getString("code");
|
||||||
|
sb.append(" and a.cwhcode = '"+code+"'");
|
||||||
|
}else{
|
||||||
|
// ts = DateUtil.dateToString(new Date(), "yyyy-MM-dd HH:mm:ss");
|
||||||
|
sb.append(" and a.dModifyDate >= '"+startTime+"'");
|
||||||
|
sb.append(" and a.dModifyDate <> '"+endTime+"'");
|
||||||
|
}
|
||||||
|
StringBuffer stringBuffer = new StringBuffer();
|
||||||
|
stringBuffer.append("select * from v_hzya_Warehouse a where 1=1 " + sb.toString());
|
||||||
|
// " WHERE 1=1 and a.id = '-2698997042624247722'");
|
||||||
|
mdmModuleSourceEntity.setDataSourceCode(dbCode);
|
||||||
|
List<HashMap<String, Object>> hashMaps = masterDataDaoImpl.queryArchivesByDataSource(stringBuffer.toString(),mdmModuleSourceEntity);
|
||||||
|
int i = 0;
|
||||||
|
if(CollectionUtils.isNotEmpty(hashMaps)){
|
||||||
|
for (HashMap<String, Object> hashMap : hashMaps) {
|
||||||
|
JSONObject main = new JSONObject();
|
||||||
|
JSONObject mdm_warehouse = new JSONObject();
|
||||||
|
for(String key:hashMap.keySet()) {
|
||||||
|
mdm_warehouse.put(key, hashMap.get(key));
|
||||||
|
}
|
||||||
|
main.put("mdm_warehouse",mdm_warehouse);
|
||||||
|
list.add(main);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<JSONObject> bindingU8Materiel(JSONObject jsonObject, MdmModuleSourceEntity mdmModuleSourceEntity, String dbCode, String startTime, String endTime) {
|
||||||
|
List<JSONObject> list = new ArrayList<>();
|
||||||
|
StringBuffer sb = new StringBuffer();
|
||||||
|
if(null != jsonObject && StrUtil.isNotEmpty(jsonObject.getString("code"))){
|
||||||
|
String code = jsonObject.getString("code");
|
||||||
|
sb.append(" and a.cinvccode = '"+code+"'");
|
||||||
|
}else{
|
||||||
|
// ts = DateUtil.dateToString(new Date(), "yyyy-MM-dd HH:mm:ss");
|
||||||
|
sb.append(" and a.dModifyDate >= '"+startTime+"'");
|
||||||
|
sb.append(" and a.dModifyDate <> '"+endTime+"'");
|
||||||
|
}
|
||||||
|
StringBuffer stringBuffer = new StringBuffer();
|
||||||
|
stringBuffer.append("select * from v_hzya_Inventory a where 1=1 " + sb.toString());
|
||||||
|
// " WHERE 1=1 and a.id = '-2698997042624247722'");
|
||||||
|
mdmModuleSourceEntity.setDataSourceCode(dbCode);
|
||||||
|
List<HashMap<String, Object>> hashMaps = masterDataDaoImpl.queryArchivesByDataSource(stringBuffer.toString(),mdmModuleSourceEntity);
|
||||||
|
int i = 0;
|
||||||
|
if(CollectionUtils.isNotEmpty(hashMaps)){
|
||||||
|
for (HashMap<String, Object> hashMap : hashMaps) {
|
||||||
|
JSONObject main = new JSONObject();
|
||||||
|
JSONObject mdm_materiel = new JSONObject();
|
||||||
|
for(String key:hashMap.keySet()) {
|
||||||
|
mdm_materiel.put(key, hashMap.get(key));
|
||||||
|
}
|
||||||
|
main.put("mdm_materiel",mdm_materiel);
|
||||||
|
list.add(main);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
//绑定银行
|
//绑定银行
|
||||||
private List<JSONObject> binDingBank(JSONObject jsonObject, MdmModuleSourceEntity mdmModuleSourceEntity, String dbCode)throws Exception {
|
private List<JSONObject> binDingBank(JSONObject jsonObject, MdmModuleSourceEntity mdmModuleSourceEntity, String dbCode)throws Exception {
|
||||||
List<JSONObject> list = new ArrayList<>();
|
List<JSONObject> list = new ArrayList<>();
|
||||||
|
@ -247,7 +367,7 @@ public class MasterDataServiceImpl extends BaseService<ComparisonEntity, String>
|
||||||
Object attribute = comparisonServiceimpl.queryEntityPage(jsonStr);
|
Object attribute = comparisonServiceimpl.queryEntityPage(jsonStr);
|
||||||
logger.info("得到的attribute值为:{}", JSON.toJSONString(attribute));
|
logger.info("得到的attribute值为:{}", JSON.toJSONString(attribute));
|
||||||
JSONObject jsonObjectAttribute = (JSONObject) JSON.toJSON(attribute);
|
JSONObject jsonObjectAttribute = (JSONObject) JSON.toJSON(attribute);
|
||||||
JSONArray jsonArrayList = jsonObjectAttribute.getJSONArray("list");
|
JSONArray jsonArrayList = jsonObjectAttribute.getJSONObject("pageInfo").getJSONArray("list");
|
||||||
//如果jsonArrayList为null,说明没有值,在表中不存在
|
//如果jsonArrayList为null,说明没有值,在表中不存在
|
||||||
if (jsonArrayList == null || jsonArrayList.size() == 0) {
|
if (jsonArrayList == null || jsonArrayList.size() == 0) {
|
||||||
// //将查询出来得数据调用通用接口新增,保存到表中
|
// //将查询出来得数据调用通用接口新增,保存到表中
|
||||||
|
|
Loading…
Reference in New Issue