|
|
|
@ -1,17 +1,27 @@
|
|
|
|
|
package com.glxp.api.service.thrsys.impl;
|
|
|
|
|
|
|
|
|
|
import cn.hutool.core.collection.CollUtil;
|
|
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
|
|
import com.github.pagehelper.PageHelper;
|
|
|
|
|
|
|
|
|
|
import com.glxp.api.constant.BasicProcessStatus;
|
|
|
|
|
import com.glxp.api.constant.Constant;
|
|
|
|
|
import com.glxp.api.dao.thrsys.ThrOrderDao;
|
|
|
|
|
import com.glxp.api.dao.thrsys.ThrOrderDetailDao;
|
|
|
|
|
import com.glxp.api.entity.thrsys.ThrOrderDetailEntity;
|
|
|
|
|
import com.glxp.api.entity.thrsys.ThrOrderEntity;
|
|
|
|
|
import com.glxp.api.entity.thrsys.*;
|
|
|
|
|
import com.glxp.api.req.thrsys.FilterThrOrderDetailRequest;
|
|
|
|
|
import com.glxp.api.req.thrsys.FilterThrOrderRequest;
|
|
|
|
|
import com.glxp.api.res.thrsys.ThrErpOrderResponse;
|
|
|
|
|
import com.glxp.api.res.thrsys.ThrOrderResponse;
|
|
|
|
|
import com.glxp.api.service.thrsys.ThrOrderImportLogService;
|
|
|
|
|
import com.glxp.api.service.thrsys.ThrOrderService;
|
|
|
|
|
import com.glxp.api.service.thrsys.ThrOrdersDlService;
|
|
|
|
|
import com.glxp.api.service.thrsys.ThrSystemBusApiService;
|
|
|
|
|
import com.glxp.api.util.CustomUtil;
|
|
|
|
|
import com.glxp.api.util.IntUtil;
|
|
|
|
|
import com.glxp.api.util.MsDateUtil;
|
|
|
|
|
import com.glxp.api.util.RedisUtil;
|
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
@ -19,8 +29,10 @@ import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
import java.util.Collections;
|
|
|
|
|
import java.util.Date;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
|
|
@Slf4j
|
|
|
|
|
@Service
|
|
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
|
|
public class ThrOrderServiceImpl implements ThrOrderService {
|
|
|
|
@ -28,6 +40,14 @@ public class ThrOrderServiceImpl implements ThrOrderService {
|
|
|
|
|
private ThrOrderDao thrOrderDao;
|
|
|
|
|
@Resource
|
|
|
|
|
private ThrOrderDetailDao thrOrderDetailDao;
|
|
|
|
|
@Resource
|
|
|
|
|
ThrSystemBusApiService thrSystemBusApiService;
|
|
|
|
|
@Resource
|
|
|
|
|
private ThrOrderImportLogService thrOrderImportLogService;
|
|
|
|
|
@Resource
|
|
|
|
|
ThrOrdersDlService thrOrdersDlService;
|
|
|
|
|
@Resource
|
|
|
|
|
RedisUtil redisUtil;
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public List<ThrOrderEntity> filterThrOrder(FilterThrOrderRequest filterThrOrderRequest) {
|
|
|
|
@ -171,4 +191,41 @@ public class ThrOrderServiceImpl implements ThrOrderService {
|
|
|
|
|
public boolean deleteAll() {
|
|
|
|
|
return thrOrderDao.deleteAll();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void downloadThrOrder(ThrSystemDetailEntity thrSystemDetailEntity) {
|
|
|
|
|
|
|
|
|
|
String data = (String) redisUtil.get(Constant.dlThrOrders);
|
|
|
|
|
if ((data != null && data.equals("true"))) {
|
|
|
|
|
log.error("当前任务正在下载更新业务单据信息,请稍后重试!");
|
|
|
|
|
return;
|
|
|
|
|
} else {
|
|
|
|
|
redisUtil.set(Constant.dlThrOrders, "true", 1);
|
|
|
|
|
List<ThrSystemBusApiEntity> thrSystemBusApiEntities = thrSystemBusApiService.list(new QueryWrapper<ThrSystemBusApiEntity>().eq("thirdSys", "thirdId").eq("type", 1));
|
|
|
|
|
if (CollUtil.isNotEmpty(thrSystemBusApiEntities)) {
|
|
|
|
|
for (ThrSystemBusApiEntity thrSystemBusApiEntity : thrSystemBusApiEntities) {
|
|
|
|
|
if (StrUtil.isNotEmpty(thrSystemBusApiEntity.getUrl()) && StrUtil.isNotEmpty(thrSystemBusApiEntity.getThirdBuyCode())) {
|
|
|
|
|
FilterThrOrderRequest filterErpOrderRequest = new FilterThrOrderRequest();
|
|
|
|
|
filterErpOrderRequest.setThirdSysFk(thrSystemDetailEntity.getThirdSysFk());
|
|
|
|
|
if (thrSystemDetailEntity.getDlLastTime() == null)
|
|
|
|
|
thrSystemDetailEntity.setDlLastTime(3 * 24);
|
|
|
|
|
Date stateDate = MsDateUtil.getBeforeDay(new Date(), IntUtil.value(thrSystemDetailEntity.getDlLastTime()));
|
|
|
|
|
filterErpOrderRequest.setStartDate(MsDateUtil.formatDate(stateDate));
|
|
|
|
|
filterErpOrderRequest.setEndDate(MsDateUtil.formatDate(new Date()));
|
|
|
|
|
filterErpOrderRequest.setBillAction(thrSystemBusApiEntity.getThirdBuyCode());
|
|
|
|
|
ThrOrderImportLogEntity thrOrderImportLogEntity = new ThrOrderImportLogEntity();
|
|
|
|
|
String genKey = CustomUtil.getId();
|
|
|
|
|
thrOrderImportLogEntity.setGenKey(genKey);
|
|
|
|
|
thrOrderImportLogEntity.setFromType("后台自动下载");
|
|
|
|
|
thrOrderImportLogEntity.setStatus(BasicProcessStatus.UDIINFO_IMPORT_UNPROCESS);
|
|
|
|
|
thrOrderImportLogEntity.setUpdateTime(new Date());
|
|
|
|
|
thrOrderImportLogEntity.setThirdSysFk("thirdId");
|
|
|
|
|
thrOrderImportLogService.insertImportLog(thrOrderImportLogEntity);
|
|
|
|
|
thrOrdersDlService.importOrders(genKey, filterErpOrderRequest.getBillAction(), filterErpOrderRequest);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|