|
|
@ -4,7 +4,6 @@ import cn.dev33.satoken.annotation.SaIgnore; |
|
|
|
import com.alibaba.fastjson.serializer.SerializerFeature; |
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|
|
|
import io.lettuce.core.dynamic.annotation.Param; |
|
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
|
import org.nl.common.exception.BadRequestException; |
|
|
|
import org.nl.common.utils.SecurityUtils; |
|
|
@ -12,10 +11,9 @@ import org.nl.wms.database.eas.dao.AllocationBill; |
|
|
|
import org.nl.wms.database.eas.dto.*; |
|
|
|
import org.nl.wms.database.eas.dao.mapper.AllocationBillMapper; |
|
|
|
import org.nl.wms.database.eas.service.IallocationBillService; |
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
|
|
|
import org.nl.wms.ext.eas.WmsToEasService; |
|
|
|
import org.nl.wms.ext.srm.WmsToSrmService; |
|
|
|
import org.springframework.beans.factory.annotation.Qualifier; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
import cn.hutool.core.util.ObjectUtil; |
|
|
|
import org.springframework.beans.BeanUtils; |
|
|
@ -23,14 +21,14 @@ import org.springframework.beans.BeanUtils; |
|
|
|
import javax.annotation.Resource; |
|
|
|
|
|
|
|
import org.nl.common.base.CommonPage; |
|
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
|
|
|
|
|
import java.time.LocalDateTime; |
|
|
|
import java.time.format.DateTimeFormatter; |
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.Map; |
|
|
|
import java.util.Set; |
|
|
|
import java.util.List; |
|
|
|
import java.util.*; |
|
|
|
import java.util.concurrent.CompletableFuture; |
|
|
|
import java.util.concurrent.ExecutionException; |
|
|
|
import java.util.concurrent.ThreadPoolExecutor; |
|
|
|
import java.util.concurrent.atomic.AtomicLong; |
|
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
|
/** |
|
|
@ -49,6 +47,9 @@ public class AllocationBillServiceImpl extends ServiceImpl<AllocationBillMapper, |
|
|
|
|
|
|
|
@Resource |
|
|
|
private WmsToEasService wmsToEasService; |
|
|
|
@Resource |
|
|
|
@Qualifier("threadPoolExecutor") |
|
|
|
private ThreadPoolExecutor pool; |
|
|
|
|
|
|
|
/** |
|
|
|
* 查询调拨单据 |
|
|
@ -58,10 +59,37 @@ public class AllocationBillServiceImpl extends ServiceImpl<AllocationBillMapper, |
|
|
|
@Override |
|
|
|
@SaIgnore |
|
|
|
public CommonPage<AllocationBillQuery> allocationPage(AllocationBillQuery params) { |
|
|
|
// 查询总记录数
|
|
|
|
long totalCount = allocationBillMapper.getAllocationCount(params.getFuzzy()); |
|
|
|
List<AllocationBillQuery> allocationBills = allocationBillMapper.allocationPage(params.getFuzzy(), params.getPage(), params.getSize()); |
|
|
|
if (!allocationBills.isEmpty()) { |
|
|
|
AtomicLong totalCount = new AtomicLong(0L); |
|
|
|
CompletableFuture<Void> count = CompletableFuture.runAsync(() -> { |
|
|
|
try { |
|
|
|
totalCount.set(allocationBillMapper.getAllocationCount(params.getFuzzy(), params.getCkbm())); |
|
|
|
} catch (Exception e) { |
|
|
|
log.error("异常信息:" + e); |
|
|
|
} |
|
|
|
}, pool); |
|
|
|
CompletableFuture<List<AllocationBillQuery>> page = CompletableFuture.supplyAsync(() -> { |
|
|
|
try { |
|
|
|
return allocationBillMapper.allocationPage(params.getFuzzy(), params.getCkbm(), params.getPage(), params.getSize()); |
|
|
|
} catch (Exception e) { |
|
|
|
log.error("异常信息:" + e); |
|
|
|
return Collections.emptyList(); |
|
|
|
} |
|
|
|
}, pool); |
|
|
|
// 等待所有异步任务完成
|
|
|
|
CompletableFuture<Void> allOf = CompletableFuture.allOf(count, page); |
|
|
|
try { |
|
|
|
allOf.get(); |
|
|
|
} catch (InterruptedException | ExecutionException e) { |
|
|
|
log.error("异步任务异常:" + e); |
|
|
|
} |
|
|
|
List<AllocationBillQuery> allocationBills = null; |
|
|
|
try { |
|
|
|
allocationBills = page.get(); |
|
|
|
} catch (InterruptedException | ExecutionException e) { |
|
|
|
log.error("获取分页结果异常:" + e); |
|
|
|
} |
|
|
|
// 处理查询结果
|
|
|
|
if (allocationBills != null && !allocationBills.isEmpty()) { |
|
|
|
allocationBills = allocationBills.stream() |
|
|
|
.peek(r -> { |
|
|
|
r.setJhdrrq(LocalDateTime.parse(r.getJhdrrq(), DateTimeFormatter.ofPattern("yyyy/MM/dd HH:mm:ss")).toLocalDate().toString()); |
|
|
@ -69,10 +97,13 @@ public class AllocationBillServiceImpl extends ServiceImpl<AllocationBillMapper, |
|
|
|
}) |
|
|
|
.collect(Collectors.toList()); |
|
|
|
} |
|
|
|
return CommonPage.getPage(allocationBills, totalCount, params.getPage(), params.getSize()); |
|
|
|
return CommonPage.getPage(allocationBills, totalCount.get(), params.getPage(), params.getSize()); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
* 分页查询 |
|
|
|
* |
|
|
@ -86,14 +117,13 @@ public class AllocationBillServiceImpl extends ServiceImpl<AllocationBillMapper, |
|
|
|
// 查询总记录数
|
|
|
|
long totalCount = allocationBillMapper.getTotalCount(params.getDjid()); |
|
|
|
List<AllocationBillQuery> allocationBillList = allocationBillMapper.allocationDetailPage(params.getPage(), params.getSize(), params.getDjid(), params.getFuzzy()); |
|
|
|
if (allocationBillList.isEmpty()) { |
|
|
|
if (!allocationBillList.isEmpty()) { |
|
|
|
allocationBillList = allocationBillList.stream().peek(r -> { |
|
|
|
if (r.getJhdrrq().contains("/") || r.getJhdcrq().contains("/")) { |
|
|
|
r.setJhdrrq(LocalDateTime.parse(r.getJhdrrq(), DateTimeFormatter.ofPattern("yyyy/MM/dd HH:mm:ss")).toLocalDate().toString()); |
|
|
|
r.setJhdcrq(LocalDateTime.parse(r.getJhdcrq(), DateTimeFormatter.ofPattern("yyyy/MM/dd HH:mm:ss")).toLocalDate().toString()); |
|
|
|
} |
|
|
|
}).collect(Collectors.toList()); |
|
|
|
} else { |
|
|
|
// 获取更新列表
|
|
|
|
List<AllocationBill> updateList = allocationBillMapper.selectList( |
|
|
|
new LambdaQueryWrapper<AllocationBill>().eq(AllocationBill::getDjid, allocationBillList.get(0).getDjid())); |
|
|
@ -167,7 +197,7 @@ public class AllocationBillServiceImpl extends ServiceImpl<AllocationBillMapper, |
|
|
|
allocationBillDto.setBillNo(params.get(0).getDjbh()); |
|
|
|
allocationBillDto.setBizDate(params.get(0).getYwrq()); |
|
|
|
allocationBillDto.setDescription(params.get(0).getBz()); |
|
|
|
allocationBillDto.setInWhUser("A110813006"); |
|
|
|
allocationBillDto.setInWhUser(SecurityUtils.getCurrentUsername()); |
|
|
|
List<AllocationBillDetailDto> entrys = new ArrayList<>(); |
|
|
|
params.forEach(r -> { |
|
|
|
AllocationBillDetailDto dto = new AllocationBillDetailDto(); |
|
|
|