|
@@ -11,14 +11,21 @@ import com.alibaba.fastjson.JSON;
|
|
import com.alibaba.fastjson.JSONArray;
|
|
import com.alibaba.fastjson.JSONArray;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.emato.biz.config.OmsConfig;
|
|
import com.emato.biz.config.OmsConfig;
|
|
|
|
+import com.emato.biz.domain.merchant.MerchUser;
|
|
|
|
+import com.emato.biz.domain.merchant.ThirdMerchantBiz;
|
|
import com.emato.biz.domain.warehouse.Page;
|
|
import com.emato.biz.domain.warehouse.Page;
|
|
import com.emato.biz.domain.warehouse.PullInveQueryVO;
|
|
import com.emato.biz.domain.warehouse.PullInveQueryVO;
|
|
|
|
+import com.emato.biz.mapper.merchant.MerchUserMapper;
|
|
|
|
+import com.emato.biz.mapper.merchant.ThirdMerchantBizMapper;
|
|
import com.emato.biz.mapper.warehouse.WbInveMngMapper;
|
|
import com.emato.biz.mapper.warehouse.WbInveMngMapper;
|
|
import com.emato.biz.util.JsonUtil;
|
|
import com.emato.biz.util.JsonUtil;
|
|
import com.emato.biz.util.OmsDataUtil;
|
|
import com.emato.biz.util.OmsDataUtil;
|
|
|
|
+import com.emato.biz.util.RoleUtils;
|
|
import com.emato.common.core.domain.AjaxResult;
|
|
import com.emato.common.core.domain.AjaxResult;
|
|
|
|
+import com.emato.common.core.domain.entity.SysUser;
|
|
import com.emato.common.exception.ServiceException;
|
|
import com.emato.common.exception.ServiceException;
|
|
import com.emato.common.utils.DateUtils;
|
|
import com.emato.common.utils.DateUtils;
|
|
|
|
+import com.emato.common.utils.SecurityUtils;
|
|
import com.emato.common.utils.oms.JacksonUtils;
|
|
import com.emato.common.utils.oms.JacksonUtils;
|
|
import com.emato.common.utils.oms.request.OmsSign;
|
|
import com.emato.common.utils.oms.request.OmsSign;
|
|
import org.apache.http.HttpStatus;
|
|
import org.apache.http.HttpStatus;
|
|
@@ -55,6 +62,12 @@ public class OWbInveMngServiceImpl implements IOWbInveMngService
|
|
@Resource
|
|
@Resource
|
|
private WbInveMngMapper wbInveMngMapper;
|
|
private WbInveMngMapper wbInveMngMapper;
|
|
|
|
|
|
|
|
+ @Resource
|
|
|
|
+ private MerchUserMapper merchUserMapper;
|
|
|
|
+
|
|
|
|
+ @Resource
|
|
|
|
+ private ThirdMerchantBizMapper thirdMerchantBizMapper;
|
|
|
|
+
|
|
private static final Logger log = LoggerFactory.getLogger(OWbInveMngServiceImpl.class);
|
|
private static final Logger log = LoggerFactory.getLogger(OWbInveMngServiceImpl.class);
|
|
|
|
|
|
@Autowired
|
|
@Autowired
|
|
@@ -75,12 +88,18 @@ public class OWbInveMngServiceImpl implements IOWbInveMngService
|
|
queryVO.setPage(page);
|
|
queryVO.setPage(page);
|
|
queryVO.setLimit(10);
|
|
queryVO.setLimit(10);
|
|
|
|
|
|
|
|
+ ThirdMerchantBiz merchantBiz = thirdMerchantBizMapper.selectByClientMerchSn(queryVO.getMerchId());
|
|
|
|
+ if (Objects.nonNull(merchantBiz)) {
|
|
|
|
+ queryVO.setThirdMerchId(merchantBiz.getThirdMerchSn());
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
// 查询 OMS 分页数据
|
|
// 查询 OMS 分页数据
|
|
Optional<Page<OWbInveMng>> firstPageOpt =
|
|
Optional<Page<OWbInveMng>> firstPageOpt =
|
|
OmsDataUtil.fetchOmsPageData(queryVO, OmsConfig.getQueryMngInveUrl(), OWbInveMng.class);
|
|
OmsDataUtil.fetchOmsPageData(queryVO, OmsConfig.getQueryMngInveUrl(), OWbInveMng.class);
|
|
|
|
|
|
// 如果有数据
|
|
// 如果有数据
|
|
- firstPageOpt.ifPresent(firstPage -> {
|
|
|
|
|
|
+ /*firstPageOpt.ifPresent(firstPage -> {
|
|
// 如果有数据,开始批量处理
|
|
// 如果有数据,开始批量处理
|
|
firstPage.getList().forEach(obj -> log.debug("拉取的 sku => {}", obj.getSku()));
|
|
firstPage.getList().forEach(obj -> log.debug("拉取的 sku => {}", obj.getSku()));
|
|
// 插入数据库
|
|
// 插入数据库
|
|
@@ -103,14 +122,14 @@ public class OWbInveMngServiceImpl implements IOWbInveMngService
|
|
rows.getAndIncrement();
|
|
rows.getAndIncrement();
|
|
});
|
|
});
|
|
// 查询 OMS 数据
|
|
// 查询 OMS 数据
|
|
- /*CompletableFuture<Void> task = CompletableFuture.runAsync(() -> {
|
|
|
|
|
|
+ CompletableFuture<Void> task = CompletableFuture.runAsync(() -> {
|
|
}, threadPoolExecutor);
|
|
}, threadPoolExecutor);
|
|
// 将任务添加到列表中
|
|
// 将任务添加到列表中
|
|
- tasks.add(task);*/
|
|
|
|
|
|
+ tasks.add(task);
|
|
}
|
|
}
|
|
CompletableFuture.allOf(tasks.toArray(new CompletableFuture[0])).join();
|
|
CompletableFuture.allOf(tasks.toArray(new CompletableFuture[0])).join();
|
|
|
|
|
|
- });
|
|
|
|
|
|
+ });*/
|
|
|
|
|
|
log.debug("拉取库存成功,拉取数据条数 => {}", rows.get());
|
|
log.debug("拉取库存成功,拉取数据条数 => {}", rows.get());
|
|
return AjaxResult.success("拉取库存成功!");
|
|
return AjaxResult.success("拉取库存成功!");
|
|
@@ -137,6 +156,32 @@ public class OWbInveMngServiceImpl implements IOWbInveMngService
|
|
@Override
|
|
@Override
|
|
public List<OWbInveMng> selectOWbInveMngList(OWbInveMng oWbInveMng)
|
|
public List<OWbInveMng> selectOWbInveMngList(OWbInveMng oWbInveMng)
|
|
{
|
|
{
|
|
|
|
+ SysUser user = SecurityUtils.getLoginUser().getUser();
|
|
|
|
+ boolean allRole = RoleUtils.isAllRole(user);
|
|
|
|
+
|
|
|
|
+ if (!allRole) {
|
|
|
|
+ // 如果没有全部数据权限
|
|
|
|
+ // 查询该用户属于哪个商户
|
|
|
|
+ MerchUser merchUser = merchUserMapper.selectMerchUserByUserId(user.getUserId()+"");
|
|
|
|
+ if (Objects.isNull(merchUser)) {
|
|
|
|
+ // 如果用户没有绑定商户就返回空数据
|
|
|
|
+ return Collections.emptyList();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // 如果用户绑定了商户
|
|
|
|
+ // 获取用户绑定的商户号,开始查询该商户的库存数据
|
|
|
|
+ String merchSn = merchUser.getMerchSn();
|
|
|
|
+ // 设置商户作为查询条件
|
|
|
|
+ oWbInveMng.setMerchSn(merchSn);
|
|
|
|
+
|
|
|
|
+ // 查询是否有三方商户
|
|
|
|
+ ThirdMerchantBiz merchantBiz = thirdMerchantBizMapper.selectByClientMerchSn(merchSn);
|
|
|
|
+ if (Objects.nonNull(merchantBiz)) {
|
|
|
|
+ // 如果有第三方商户,设置三方商户号作为查询条件
|
|
|
|
+ oWbInveMng.setThirdMerchSn(merchantBiz.getThirdMerchSn());
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
return wbInveMngMapper.selectWbInveMngList(oWbInveMng);
|
|
return wbInveMngMapper.selectWbInveMngList(oWbInveMng);
|
|
}
|
|
}
|
|
|
|
|