|
@@ -11,6 +11,7 @@ import com.iamberry.rst.core.dm.DealerChannel;
|
|
|
import com.iamberry.rst.core.dm.DealerProduct;
|
|
|
import com.iamberry.rst.core.order.*;
|
|
|
import com.iamberry.rst.core.page.PagedResult;
|
|
|
+import com.iamberry.rst.core.sys.SysConfig;
|
|
|
import com.iamberry.rst.core.tools.LogisticsInfo;
|
|
|
import com.iamberry.rst.faces.address.AddressService;
|
|
|
import com.iamberry.rst.faces.cm.SalesOrderService;
|
|
@@ -24,6 +25,7 @@ import com.iamberry.rst.service.order.mapper.OrderSyncLogMapper;
|
|
|
import com.iamberry.rst.service.order.mapper.OrderSyncPlatformMapper;
|
|
|
import com.iamberry.rst.service.product.mapper.ProductColorMapper;
|
|
|
import com.iamberry.rst.service.product.mapper.ProductMapper;
|
|
|
+import com.iamberry.rst.service.sys.mapper.SysConfigMapper;
|
|
|
import com.iamberry.rst.util.GenerateKeyUtil;
|
|
|
import com.iamberry.rst.util.PageUtil;
|
|
|
import org.apache.http.HttpResponse;
|
|
@@ -38,10 +40,12 @@ import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
import java.io.BufferedReader;
|
|
|
import java.io.InputStream;
|
|
|
import java.io.InputStreamReader;
|
|
|
+import java.text.ParseException;
|
|
|
import java.text.SimpleDateFormat;
|
|
|
import java.util.*;
|
|
|
|
|
@@ -77,6 +81,8 @@ public class OrderSyncLogServiceImpl implements OrderSyncLogService {
|
|
|
private AddressService addressService;
|
|
|
@Autowired
|
|
|
private ProductMapper productMapper;
|
|
|
+ @Autowired
|
|
|
+ private SysConfigMapper sysConfigMapper;
|
|
|
|
|
|
//Map最大容量
|
|
|
static int maxSize = 20;
|
|
@@ -96,6 +102,10 @@ public class OrderSyncLogServiceImpl implements OrderSyncLogService {
|
|
|
return orderSyncPlatformMapper.getSyncPlatformById(XYT_ID);
|
|
|
}
|
|
|
|
|
|
+ //配置小亚通拉取订单时间参数设置id
|
|
|
+ private static final Integer CONFIG_ID = 9;
|
|
|
+ SimpleDateFormat SYS_CONFIG_SDF = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
+
|
|
|
|
|
|
/**
|
|
|
* 获取集合
|
|
@@ -140,7 +150,30 @@ public class OrderSyncLogServiceImpl implements OrderSyncLogService {
|
|
|
* @return
|
|
|
*/
|
|
|
@Override
|
|
|
+ @Transactional
|
|
|
public synchronized Integer syncXYTOrder(Integer type,Date creatTime) {
|
|
|
+ if(type == 1){
|
|
|
+ SysConfig sysConfig = sysConfigMapper.getSysConfigAllLock(CONFIG_ID);
|
|
|
+ Date date = new Date();
|
|
|
+ try {
|
|
|
+ date = SYS_CONFIG_SDF.parse(sysConfig.getConfigRemarks());
|
|
|
+ } catch (ParseException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ logger.info("获取配置文件失败!");
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+ Long timeDifference = date.getTime() - new Date().getTime();
|
|
|
+ timeDifference = Math.abs(timeDifference);
|
|
|
+ if(timeDifference < 270000){
|
|
|
+ Integer configParameter = Integer.valueOf(sysConfig.getConfigParameter());
|
|
|
+ if(2 == configParameter){
|
|
|
+ logger.info("该定时任务已经运行!");
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
OrderSyncPlatform orderSyncPlatform = getXYTPlatform();
|
|
|
if(orderSyncPlatform.getSyncPlatStatus() != 1){
|
|
|
logger.info("小亚通接口已关闭!");
|
|
@@ -232,7 +265,7 @@ public class OrderSyncLogServiceImpl implements OrderSyncLogService {
|
|
|
if(orderSyncLog.getSyncLogRecentNum() != 0){
|
|
|
//该条查询当天最近的一条日志,与当前日志想匹配,如果错误相同,则不处理,如果不相同与添加日志,进一步节省sql存储空间
|
|
|
OrderSyncLog osl = orderSyncLogMapper.getSyncLogLast(orderSyncPlatform.getSyncPlatId());
|
|
|
- if(osl != null){
|
|
|
+ if(osl != null && orderSyncLog.getSyncLogErrorMsg() != null){
|
|
|
if(!orderSyncLog.getSyncLogErrorMsg().equals(osl.getSyncLogErrorMsg())){
|
|
|
orderSyncLogMapper.save(orderSyncLog);
|
|
|
}
|
|
@@ -268,6 +301,18 @@ public class OrderSyncLogServiceImpl implements OrderSyncLogService {
|
|
|
orderSyncPlatformMapper.update(newOrderSyncPlatform);
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ if(type == 1){
|
|
|
+ //修改配置文件
|
|
|
+ Calendar newConfigDate = Calendar.getInstance();
|
|
|
+ newConfigDate.set(Calendar.SECOND,0);
|
|
|
+
|
|
|
+ SysConfig newSysConfig = new SysConfig();
|
|
|
+ newSysConfig.setConfigId(CONFIG_ID);
|
|
|
+ newSysConfig.setConfigParameter("2");
|
|
|
+ newSysConfig.setConfigRemarks(SYS_CONFIG_SDF.format(newConfigDate.getTime()));
|
|
|
+ sysConfigMapper.updateSysConfig(newSysConfig);
|
|
|
+ }
|
|
|
return amountSuccessAllNum;
|
|
|
}
|
|
|
|