提交 d4ac15df authored 作者: inroi's avatar inroi

微调

上级 303f56ee
...@@ -9,7 +9,7 @@ import com.system.model.DelayedElement; ...@@ -9,7 +9,7 @@ import com.system.model.DelayedElement;
import com.system.model.InitConnectParam; import com.system.model.InitConnectParam;
import com.system.utils.HttpUtil; import com.system.utils.HttpUtil;
import com.system.utils.JsonUtil; import com.system.utils.JsonUtil;
import com.system.utils.MallLogUtil; import com.system.utils.ProductLogUtil;
import com.system.utils.StringUtil; import com.system.utils.StringUtil;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
...@@ -45,13 +45,12 @@ public class CommonHttpApi { ...@@ -45,13 +45,12 @@ public class CommonHttpApi {
private InitConnectParamMapper initConnectParamMapper; private InitConnectParamMapper initConnectParamMapper;
@Autowired @Autowired
private MallLogUtil mallLogUtil; private ProductLogUtil productLogUtil;
@PostConstruct @PostConstruct
public void init() { public void init() {
initConnectParam = initConnectParamMapper.selectOne(new QueryWrapper<InitConnectParam>().last("LIMIT 1")); initConnectParam = initConnectParamMapper.selectOne(new QueryWrapper<InitConnectParam>().last("LIMIT 1"));
System.out.println("++++++" + initConnectParam);
if (StringUtil.isNotNull(initConnectParam)) { if (StringUtil.isNotNull(initConnectParam)) {
mallAddress = initConnectParam.getMallAddress(); mallAddress = initConnectParam.getMallAddress();
} }
...@@ -113,22 +112,20 @@ public class CommonHttpApi { ...@@ -113,22 +112,20 @@ public class CommonHttpApi {
} }
} }
public String commonHttpGet(Map<String, String> config, String queueId, String name, List<String> keyList, Map<String, Object> where) { public String commonHttpSyncData(Map<String, String> config, String queueId, String name, List<String> keyList, Map<String, Object> where) {
Map<String, Object> request = new HashMap<>(3); Map<String, Object> request = new HashMap<>(3);
request.put("formId", config.get("sFormId")); request.put("form", config.get("sFormId"));
request.put("fieldKeys", String.join(",", keyList)); request.put("fields", String.join(",", keyList));
request.put("filterString", this.stringWhere(where)); request.putAll(where);
String response;
try { try {
response = HttpUtil.httpPost("", JsonUtil.toString(request)).getBody(); String response = HttpUtil.httpPost("http://192.168.0.9:8089/wx/" + "api/dataSyn/synData", JsonUtil.toString(request)).getBody();
mallLogUtil.mallLogCreate(name, config.get("docType"), queueId, Integer.valueOf(config.get("operation")), JsonUtil.toString(request), response); productLogUtil.productSyncLogCreate(Integer.valueOf(config.get("productId")), queueId, name, config.get("docType"), config.get("direction"), JsonUtil.toString(request), response);
return response;
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
throw new MallCommonException(LOGIN_MESSAGE); throw new MallCommonException(LOGIN_MESSAGE);
} }
return response;
} }
public String sendThirdParty(String receiveAddress, String data, int index) { public String sendThirdParty(String receiveAddress, String data, int index) {
...@@ -154,7 +151,7 @@ public class CommonHttpApi { ...@@ -154,7 +151,7 @@ public class CommonHttpApi {
} }
//TODO 开启同步 //TODO 开启同步
HttpUtil.httpGet("http://integrate-system:8090/integrate/api/start/synchronization"); //HttpUtil.httpGet("http://integrate-system:8090/integrate/api/start/synchronization");
}); });
} }
......
...@@ -20,6 +20,9 @@ public interface Constants { ...@@ -20,6 +20,9 @@ public interface Constants {
String SUCCESS_NAME = "success"; String SUCCESS_NAME = "success";
String CODE_NAME = "code";
String DATE_NAME = "data"; String DATE_NAME = "data";
......
...@@ -7,7 +7,8 @@ ...@@ -7,7 +7,8 @@
<select id="mallCommonConfigList" parameterType="java.lang.Integer" resultType="com.system.transfer.form.MallCommonConfigListOutVoRecords"> <select id="mallCommonConfigList" parameterType="java.lang.Integer" resultType="com.system.transfer.form.MallCommonConfigListOutVoRecords">
SELECT SELECT
id, platform_product_relation_id, doc_type, s_form_id, `name`,direction, operation, entry_name, custom_sql, create_time id, platform_product_relation_id, doc_type, s_form_id, `name`, direction,
operation, encapsulation_format, entry_name, custom_sql, create_time
FROM tb_mall_common_config WHERE operation = #{operation} FROM tb_mall_common_config WHERE operation = #{operation}
</select> </select>
...@@ -17,7 +18,8 @@ ...@@ -17,7 +18,8 @@
<select id="mallCommonConfigGetList" resultType="com.system.transfer.form.MallCommonConfigListOutVoRecords"> <select id="mallCommonConfigGetList" resultType="com.system.transfer.form.MallCommonConfigListOutVoRecords">
SELECT SELECT
m1.id, m1.platform_product_relation_id, m1.doc_type, m1.s_form_id, m1.name, m1.direction, m1.operation, m1.entry_name, m1.custom_sql, m1.create_time m1.id, m1.platform_product_relation_id, m1.doc_type, m1.s_form_id, m1.name, m1.direction,
m1.operation, m1.encapsulation_format, m1.entry_name, m1.custom_sql, m1.create_time
FROM tb_mall_common_config AS m1 INNER JOIN ( FROM tb_mall_common_config AS m1 INNER JOIN (
SELECT SELECT
platform_product_relation_id, s_form_id, MIN(operation) AS operation platform_product_relation_id, s_form_id, MIN(operation) AS operation
...@@ -31,7 +33,8 @@ ...@@ -31,7 +33,8 @@
<select id="getMallCommonConfigById" parameterType="java.lang.Integer" resultType="com.system.transfer.form.MallCommonConfigListOutVoRecords"> <select id="getMallCommonConfigById" parameterType="java.lang.Integer" resultType="com.system.transfer.form.MallCommonConfigListOutVoRecords">
SELECT SELECT
id, platform_product_relation_id, doc_type, s_form_id, `name`,direction, operation, entry_name, custom_sql, create_time id, platform_product_relation_id, doc_type, s_form_id, `name`, direction,
operation, encapsulation_format, entry_name, custom_sql, create_time
FROM tb_mall_common_config WHERE id = #{id} FROM tb_mall_common_config WHERE id = #{id}
</select> </select>
......
...@@ -8,9 +8,9 @@ ...@@ -8,9 +8,9 @@
SELECT SELECT
s.id, s.platform_product_relation_id, s.job_class_name, s.common_config_id, s.id, s.platform_product_relation_id, s.job_class_name, s.common_config_id,
k.doc_type, k.s_form_id, s.receive_address, s.create_time m.doc_type, m.s_form_id, s.receive_address, s.create_time
FROM tb_synchronization_operation AS s FROM tb_synchronization_operation AS s
LEFT JOIN tb_kingdee_common_config AS k ON s.common_config_id = k.id LEFT JOIN tb_mall_common_config AS m ON s.common_config_id = m.id
WHERE job_class_name = "com.system.quartz.job.mallSynchronizationJob" WHERE job_class_name = "com.system.quartz.job.mallSynchronizationJob"
</select> </select>
......
...@@ -22,7 +22,7 @@ ...@@ -22,7 +22,7 @@
INSERT INTO tb_mall_synchronization_record_temp (fid, data_id, entry_id, form, operation) VALUES INSERT INTO tb_mall_synchronization_record_temp (fid, data_id, entry_id, form, operation) VALUES
<foreach collection="tempList" item="item" separator=","> <foreach collection="tempList" item="item" separator=",">
(#{item.fid}, #{item.dataId}, #{item.entryId}, #{item.sFormId}, #{item.operation}) (#{item.id}, #{item.dataId}, #{item.entryId}, #{item.form}, #{item.operation})
</foreach> </foreach>
ON DUPLICATE KEY UPDATE ON DUPLICATE KEY UPDATE
fid = VALUES (fid), data_id = VALUES (data_id), entry_id = VALUES (entry_id), fid = VALUES (fid), data_id = VALUES (data_id), entry_id = VALUES (entry_id),
...@@ -46,7 +46,7 @@ ...@@ -46,7 +46,7 @@
INSERT INTO tb_mall_synchronization_record (fid, data_id, entry_id, form, operation) VALUES INSERT INTO tb_mall_synchronization_record (fid, data_id, entry_id, form, operation) VALUES
<foreach collection="tempList" item="item" separator=","> <foreach collection="tempList" item="item" separator=",">
(#{item.fid}, #{item.dataId}, #{item.entryId}, #{item.sFormId}, #{item.operation}) (#{item.id}, #{item.dataId}, #{item.entryId}, #{item.form}, #{item.operation})
</foreach> </foreach>
ON DUPLICATE KEY UPDATE ON DUPLICATE KEY UPDATE
fid = VALUES (fid), data_id = VALUES (data_id), entry_id = VALUES (entry_id), fid = VALUES (fid), data_id = VALUES (data_id), entry_id = VALUES (entry_id),
......
...@@ -25,6 +25,7 @@ public class MallCommonApi { ...@@ -25,6 +25,7 @@ public class MallCommonApi {
public List<Map<String, Object>> getSynchronizationRecords() { public List<Map<String, Object>> getSynchronizationRecords() {
try { try {
String response = commonHttpApi.commonHttpSync(); String response = commonHttpApi.commonHttpSync();
System.out.println("同步记录: " + response);
List<Object> objectList = JsonUtil.toList(response, Object.class); List<Object> objectList = JsonUtil.toList(response, Object.class);
if (!CollectionUtils.isEmpty(objectList)) { if (!CollectionUtils.isEmpty(objectList)) {
......
...@@ -3,6 +3,7 @@ package com.system.mall; ...@@ -3,6 +3,7 @@ package com.system.mall;
import com.system.api.CommonApi; import com.system.api.CommonApi;
import com.system.api.CommonHttpApi; import com.system.api.CommonHttpApi;
import com.system.constants.Constants; import com.system.constants.Constants;
import com.system.constants.MallConstants;
import com.system.transfer.form.MallFieldMappingListOutVoRecords; import com.system.transfer.form.MallFieldMappingListOutVoRecords;
import com.system.utils.FormFieldMappingUtil; import com.system.utils.FormFieldMappingUtil;
import com.system.utils.JsonUtil; import com.system.utils.JsonUtil;
...@@ -30,18 +31,19 @@ public class MallCommonSyncApi { ...@@ -30,18 +31,19 @@ public class MallCommonSyncApi {
List<MallFieldMappingListOutVoRecords> fieldList = FormFieldMappingUtil.encapsulationMapping(config.get("formFieldMappingDetail")); List<MallFieldMappingListOutVoRecords> fieldList = FormFieldMappingUtil.encapsulationMapping(config.get("formFieldMappingDetail"));
List<String> keyList = fieldList.stream().map(MallFieldMappingListOutVoRecords::getFieldBeforeMapping).collect(Collectors.toList()); List<String> keyList = fieldList.stream().map(MallFieldMappingListOutVoRecords::getFieldBeforeMapping).collect(Collectors.toList());
String response = commonHttpApi.commonHttpGet(config, queueId, name, keyList, where); String response = commonHttpApi.commonHttpSyncData(config, queueId, name, keyList, where);
System.out.println("同步记录详细数据: " + response);
Map<String, Object> map = JsonUtil.toMap(response, String.class, Object.class); Map<String, Object> map = JsonUtil.toMap(response, String.class, Object.class);
if (!CollectionUtils.isEmpty(map)) { if (!CollectionUtils.isEmpty(map)) {
if (Constants.SUCCESS_CODE.equals(String.valueOf(map.get(Constants.SUCCESS_NAME)))) { if (MallConstants.SUCCESS_CODE.equals(String.valueOf(map.get(Constants.CODE_NAME)))) {
List<Object> objectList = JsonUtil.toList(JsonUtil.toString(map.get("data")), Object.class); List<Object> objectList = JsonUtil.toList(JsonUtil.toString(map.get("data")), Object.class);
List<Map<String, Object>> dataList = objectList.stream().map(m -> JsonUtil.toMap(JsonUtil.toString(m), String.class, Object.class)).collect(Collectors.toList()); List<Map<String, Object>> dataList = objectList.stream().map(m -> JsonUtil.toMap(JsonUtil.toString(m), String.class, Object.class)).collect(Collectors.toList());
result.put("data", CommonApi.encapsulationData(config, queueId, dataList, fieldList)); result.put("data", CommonApi.encapsulationData(config, queueId, dataList, fieldList));
result.put("success", true); result.put("success", true);
} }
} else if (!Constants.SUCCESS_CODE.equals(String.valueOf(map.get(Constants.SUCCESS_NAME))) && map.containsKey(Constants.ERROR_MESSAGE)) { } else if (!MallConstants.SUCCESS_CODE.equals(String.valueOf(map.get(Constants.CODE_NAME))) && map.containsKey(Constants.ERROR_MESSAGE)) {
result.put("message", map.get(Constants.ERROR_MESSAGE)); result.put("message", map.get(Constants.ERROR_MESSAGE));
result.put("success", false); result.put("success", false);
} else { } else {
......
...@@ -45,7 +45,7 @@ public class IMallSyncServiceImpl implements IMallSyncService { ...@@ -45,7 +45,7 @@ public class IMallSyncServiceImpl implements IMallSyncService {
@Override @Override
public void synchronization(Integer id, String sFormId, Integer dataId, Integer entryId) { public void synchronization(Integer id, String sFormId, Integer dataId, Integer entryId) {
List<Map<String, String>> configList = mallCommonSyncConstants.get(sFormId); List<Map<String, String>> configList = mallCommonSyncConstants.get(sFormId);
if (!CollectionUtils.isEmpty(configList)) { if (CollectionUtils.isEmpty(configList)) {
synchronizationRecordsMapper.synchronizationRecordsUpdate(new SynchronizationRecordsUpdateInVo(id, SnowFlakeIdUtil.generateId().toString(), "商城同步失败! sFormId为: " + sFormId + " 的商城表单不存在", 2)); synchronizationRecordsMapper.synchronizationRecordsUpdate(new SynchronizationRecordsUpdateInVo(id, SnowFlakeIdUtil.generateId().toString(), "商城同步失败! sFormId为: " + sFormId + " 的商城表单不存在", 2));
return; return;
} }
...@@ -61,7 +61,6 @@ public class IMallSyncServiceImpl implements IMallSyncService { ...@@ -61,7 +61,6 @@ public class IMallSyncServiceImpl implements IMallSyncService {
} }
Map<String, Object> where = new HashMap<>(3); Map<String, Object> where = new HashMap<>(3);
where.put("form", sFormId);
where.put("dataId", dataId); where.put("dataId", dataId);
if (StringUtil.isNotNull(entryId)) { if (StringUtil.isNotNull(entryId)) {
where.put("entryId", entryId); where.put("entryId", entryId);
...@@ -78,10 +77,10 @@ public class IMallSyncServiceImpl implements IMallSyncService { ...@@ -78,10 +77,10 @@ public class IMallSyncServiceImpl implements IMallSyncService {
} }
private void encapsulationRequest(Map<String, String> config, Map<String, String> operation, String queueId, Integer id, Map<String, Object> data) { private void encapsulationRequest(Map<String, String> config, Map<String, String> operation, String queueId, Integer id, Map<String, Object> data) {
Map<String, Object> request = new HashMap<>(); Map<String, Object> request = new HashMap<>(3);
request.put("docType", config.get("docType")); request.put("docType", config.get("docType"));
request.put("updateType", "update"); request.put("updateType", "update");
request.put("data", data.get(Constants.DATE_NAME)); request.put("data", JsonUtil.toList(JsonUtil.toString(data.get(Constants.DATE_NAME)), Object.class));
String response = mallCommonSyncApi.sendThirdParty(operation.get("receiveAddress"), JsonUtil.toString(request)); String response = mallCommonSyncApi.sendThirdParty(operation.get("receiveAddress"), JsonUtil.toString(request));
//记录第三方日志 //记录第三方日志
productLogUtil.productHttpLogCreate(Integer.valueOf(config.get("productId")), queueId, id, config.get("name"), config.get("docType"), config.get("direction"), JsonUtil.toString(request), response); productLogUtil.productHttpLogCreate(Integer.valueOf(config.get("productId")), queueId, id, config.get("name"), config.get("docType"), config.get("direction"), JsonUtil.toString(request), response);
......
...@@ -74,8 +74,8 @@ public class SynchronizationServiceImpl implements ISynchronizationService { ...@@ -74,8 +74,8 @@ public class SynchronizationServiceImpl implements ISynchronizationService {
} }
for (SynchronizationRecordsListOutVoRecords records : recordsList) { for (SynchronizationRecordsListOutVoRecords records : recordsList) {
if (!"LQKJ_IMSSync".equals(records.getSFormId())) { if (!"LQKJ_IMSSync".equals(records.getForm())) {
mallSyncService.synchronization(records.getId(), records.getSFormId(), records.getDataId(), records.getEntryId()); mallSyncService.synchronization(records.getId(), records.getForm(), records.getDataId(), records.getEntryId());
} }
if (Thread.currentThread().isInterrupted()) { if (Thread.currentThread().isInterrupted()) {
break; break;
......
...@@ -33,9 +33,9 @@ public class SynchronizationRecordsListOutVoRecords { ...@@ -33,9 +33,9 @@ public class SynchronizationRecordsListOutVoRecords {
/** /**
* 金蝶标识 * 商城标识
*/ */
private String sFormId; private String form;
/** /**
......
...@@ -72,6 +72,7 @@ public class JsonUtil { ...@@ -72,6 +72,7 @@ public class JsonUtil {
try { try {
return MAPPER.readValue(json, MAPPER.getTypeFactory().constructMapType(Map.class, kClass, vClass)); return MAPPER.readValue(json, MAPPER.getTypeFactory().constructMapType(Map.class, kClass, vClass));
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace();
log.error("Json解析出错: JsonUtil.toMap(), Json: " + json); log.error("Json解析出错: JsonUtil.toMap(), Json: " + json);
return new HashMap<>(10); return new HashMap<>(10);
} }
......
...@@ -126,6 +126,12 @@ public class ProductLogUtil { ...@@ -126,6 +126,12 @@ public class ProductLogUtil {
encapsulationOperation(response, inVo); encapsulationOperation(response, inVo);
} }
public void productSyncLogCreate(Integer productId, String queueId, String name, String code, String direction, String request, String response) {
ProductLogCreateInVo inVo = this.encapsulationInVo(productId, queueId, name, code, direction, request, response);
productLogMapper.productLogCreate(inVo);
}
public void productSyncErrorLogCreate(Integer productId, String queueId, String name, String code, String direction, String request, String message) { public void productSyncErrorLogCreate(Integer productId, String queueId, String name, String code, String direction, String request, String message) {
ProductLogCreateInVo inVo = this.encapsulationInVo(productId, queueId, name, code, direction, request, message); ProductLogCreateInVo inVo = this.encapsulationInVo(productId, queueId, name, code, direction, request, message);
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论