Browse Source

add: 增加延迟测试;

test-20240527
龚宝雄 4 months ago
parent
commit
e81cabb181
  1. 6
      nlsso-server/src/main/java/org/nl/wms/database/eas/dao/EasOutInBillDetail.java
  2. 15
      nlsso-server/src/main/java/org/nl/wms/database/eas/dao/ReceiptBill.java
  3. 9
      nlsso-server/src/main/java/org/nl/wms/database/eas/dto/ReceiptBillQuery.java
  4. 113
      nlsso-server/src/main/java/org/nl/wms/database/eas/service/impl/EasOutInBillDetailServiceImpl.java
  5. 7
      nlsso-server/src/main/java/org/nl/wms/database/eas/service/impl/ReceiptBillServiceImpl.java
  6. 4
      nlsso-server/src/main/java/org/nl/wms/schedule/EasBillSchedule.java
  7. 12
      nlsso-server/src/main/resources/config/application-devLocal.yml

6
nlsso-server/src/main/java/org/nl/wms/database/eas/dao/EasOutInBillDetail.java

@ -43,6 +43,12 @@ public class EasOutInBillDetail extends Model<EasOutInBillDetail> {
*/ */
private String id; private String id;
/**
* 物料总数
*/
@TableField(exist = false)
private Double wlzs;
/** /**
* 单据id * 单据id

15
nlsso-server/src/main/java/org/nl/wms/database/eas/dao/ReceiptBill.java

@ -28,12 +28,20 @@ public class ReceiptBill extends Model<ReceiptBill> {
*/ */
@TableId(value = "flid", type = IdType.NONE) @TableId(value = "flid", type = IdType.NONE)
private String flid; private String flid;
/**
* 收货数量
*/
private String shsl;
/**
* 物料总数
*/
@TableField(exist = false)
private Double wlzs;
/** /**
* 审核结果 * 审核结果
*/ */
private String shjg; private String shjg;
/** /**
* 送货单id * 送货单id
*/ */
@ -102,10 +110,7 @@ public class ReceiptBill extends Model<ReceiptBill> {
* 本次送货数量 * 本次送货数量
*/ */
private String bcshsl; private String bcshsl;
/**
* 收货数量
*/
private String shsl;
/** /**
* 件数 * 件数
*/ */

9
nlsso-server/src/main/java/org/nl/wms/database/eas/dto/ReceiptBillQuery.java

@ -23,6 +23,10 @@ public class ReceiptBillQuery extends BaseQuery<ReceiptBillQuery> {
private String djid; private String djid;
/**
* 收货数量
*/
private String shsl;
/** /**
* 送货单号 * 送货单号
@ -90,10 +94,7 @@ public class ReceiptBillQuery extends BaseQuery<ReceiptBillQuery> {
private String bcshsl; private String bcshsl;
/**
* 收货数量
*/
private String shsl;
/** /**

113
nlsso-server/src/main/java/org/nl/wms/database/eas/service/impl/EasOutInBillDetailServiceImpl.java

@ -1,34 +1,34 @@
package org.nl.wms.database.eas.service.impl; package org.nl.wms.database.eas.service.impl;
import cn.hutool.core.date.DateUtil; import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.nl.common.base.CommonPage;
import org.nl.common.exception.BadRequestException; import org.nl.common.exception.BadRequestException;
import org.nl.common.utils.SecurityUtils; import org.nl.common.utils.SecurityUtils;
import org.nl.wms.database.eas.dao.*; import org.nl.wms.database.eas.dao.EasOutInBillDetail;
import org.nl.wms.database.eas.dto.*; import org.nl.wms.database.eas.dao.InventoryInfo;
import org.nl.wms.database.eas.dao.mapper.EasOutInBillDetailMapper; import org.nl.wms.database.eas.dao.mapper.EasOutInBillDetailMapper;
import org.nl.wms.database.eas.dto.EasOutInBillDetailVO;
import org.nl.wms.database.eas.service.IeasOutInBillDetailService; import org.nl.wms.database.eas.service.IeasOutInBillDetailService;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.nl.wms.database.eas.service.IeasOutInBillService; import org.nl.wms.database.eas.service.IeasOutInBillService;
import org.springframework.beans.BeanUtils;
import org.springframework.scheduling.annotation.Async; import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import cn.hutool.core.util.ObjectUtil;
import org.springframework.beans.BeanUtils;
import javax.annotation.Resource;
import org.nl.common.base.CommonPage;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.*; import java.util.List;
import java.util.concurrent.CompletableFuture; import java.util.Map;
import java.util.Objects;
import java.util.Set;
import java.util.function.Function; import java.util.function.Function;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@ -64,40 +64,51 @@ public class EasOutInBillDetailServiceImpl extends ServiceImpl<EasOutInBillDetai
.eq(ObjectUtil.isNotEmpty(params), EasOutInBillDetail::getDjid, params.getDjid()) .eq(ObjectUtil.isNotEmpty(params), EasOutInBillDetail::getDjid, params.getDjid())
); );
List<EasOutInBillDetail> easOutInBillDetailList = result.getRecords(); List<EasOutInBillDetail> easOutInBillDetailList = result.getRecords();
List<InventoryInfo> inventoryInfoList = queryInventoryInfoList(easOutInBillDetailList); for (int i = 0; i < easOutInBillDetailList.size(); i++) {
easOutInBillDetailList.forEach(bill -> { long se = 10L;
//查询库存信息 easOutInBillDetailList.get(i).setKcsl(BigDecimal.valueOf(se + i * 10L));
List<InventoryInfo> matchedInventory = inventoryInfoList.stream()
.filter(inventory -> {
boolean isMatched = true;
//去向部门
if (bill.getZzbm() != null && !bill.getZzbm().isEmpty()) {
isMatched = Objects.equals(inventory.getZzbm(), bill.getZzbm());
}
//仓库编码
if (bill.getCkbm() != null && !bill.getCkbm().isEmpty()) {
isMatched = Objects.equals(inventory.getCkbm(), bill.getCkbm());
}
//库位编码
if (bill.getTjkwbm() != null && !bill.getTjkwbm().isEmpty()) {
isMatched = Objects.equals(inventory.getTjkwbm(), bill.getTjkwbm());
} }
//计算相同物料编码的总数
//物料编码 Map<String, Double> totalQty = easOutInBillDetailList.stream()
if (bill.getWlbm() != null && !bill.getWlbm().isEmpty()) { .collect(Collectors.groupingBy(EasOutInBillDetail::getWlbm, Collectors.summingDouble(bill -> bill.getSl().doubleValue())));
isMatched = Objects.equals(inventory.getWlbm(), bill.getWlbm()); easOutInBillDetailList.forEach(bill -> {
} //设置物料总数
// 批次 bill.setWlzs(totalQty.get(bill.getWlbm()));
if (bill.getPc() != null && !bill.getPc().isEmpty()) { });
isMatched = Objects.equals(inventory.getPc(), bill.getPc()); // List<InventoryInfo> inventoryInfoList = queryInventoryInfoList(easOutInBillDetailList);
} // easOutInBillDetailList.forEach(bill -> {
// 跟踪号 // //查询库存信息
if (bill.getTrackno() != null && !bill.getTrackno().isEmpty()) { // List<InventoryInfo> matchedInventory = inventoryInfoList.stream()
isMatched = Objects.equals(inventory.getTrackno(), bill.getTrackno()); // .filter(inventory -> {
} // boolean isMatched = true;
return isMatched; // //去向部门
}) // if (bill.getZzbm() != null && !bill.getZzbm().isEmpty()) {
.collect(Collectors.toList()); // isMatched = Objects.equals(inventory.getZzbm(), bill.getZzbm());
// }
// //仓库编码
// if (bill.getCkbm() != null && !bill.getCkbm().isEmpty()) {
// isMatched = Objects.equals(inventory.getCkbm(), bill.getCkbm());
// }
// //库位编码
// if (bill.getTjkwbm() != null && !bill.getTjkwbm().isEmpty()) {
// isMatched = Objects.equals(inventory.getTjkwbm(), bill.getTjkwbm());
// }
//
// //物料编码
// if (bill.getWlbm() != null && !bill.getWlbm().isEmpty()) {
// isMatched = Objects.equals(inventory.getWlbm(), bill.getWlbm());
// }
// // 批次
// if (bill.getPc() != null && !bill.getPc().isEmpty()) {
// isMatched = Objects.equals(inventory.getPc(), bill.getPc());
// }
// // 跟踪号
// if (bill.getTrackno() != null && !bill.getTrackno().isEmpty()) {
// isMatched = Objects.equals(inventory.getTrackno(), bill.getTrackno());
// }
// return isMatched;
// })
// .collect(Collectors.toList());
// List<InventoryInfo> matchedInventory = inventoryInfoList.stream() // List<InventoryInfo> matchedInventory = inventoryInfoList.stream()
// .filter(inventory -> Objects.equals(inventory.getZzbm(), bill.getZzbm()) // .filter(inventory -> Objects.equals(inventory.getZzbm(), bill.getZzbm())
// && Objects.equals(inventory.getCkbm(), bill.getCkbm()) // && Objects.equals(inventory.getCkbm(), bill.getCkbm())
@ -106,11 +117,11 @@ public class EasOutInBillDetailServiceImpl extends ServiceImpl<EasOutInBillDetai
// && Objects.equals(inventory.getTrackno(), bill.getTrackno()) // && Objects.equals(inventory.getTrackno(), bill.getTrackno())
// && Objects.equals(inventory.getKwbm(), bill.getKwbm())) // && Objects.equals(inventory.getKwbm(), bill.getKwbm()))
// .collect(Collectors.toList()); // .collect(Collectors.toList());
Optional<InventoryInfo> minKcsl = matchedInventory.stream() // Optional<InventoryInfo> minKcsl = matchedInventory.stream()
.filter(r -> r.getUnitno().equals(bill.getJldw())) // .filter(r -> r.getUnitno().equals(bill.getJldw()))
.min(Comparator.comparing(InventoryInfo::getKcsl)); // .min(Comparator.comparing(InventoryInfo::getKcsl));
minKcsl.ifPresent(m -> bill.setKcsl(m.getKcsl())); // minKcsl.ifPresent(m -> bill.setKcsl(m.getKcsl()));
}); // });
result.setRecords(easOutInBillDetailList); result.setRecords(easOutInBillDetailList);
return CommonPage.getPage(result); return CommonPage.getPage(result);
} }

7
nlsso-server/src/main/java/org/nl/wms/database/eas/service/impl/ReceiptBillServiceImpl.java

@ -81,6 +81,9 @@ public class ReceiptBillServiceImpl extends ServiceImpl<ReceiptBillMapper, Recei
Page<ReceiptBill> pageObject = new Page<>(params.getPage(), params.getSize()); Page<ReceiptBill> pageObject = new Page<>(params.getPage(), params.getSize());
Page<ReceiptBill> receiptBills = receiptBillMapper.receiptDetailPage(pageObject, params.getDjid(), params.getFuzzy()); Page<ReceiptBill> receiptBills = receiptBillMapper.receiptDetailPage(pageObject, params.getDjid(), params.getFuzzy());
List<ReceiptBill> receiptBillList = receiptBills.getRecords(); List<ReceiptBill> receiptBillList = receiptBills.getRecords();
//计算相同物料编码的总数
Map<String, Double> totalQty = receiptBillList.stream()
.collect(Collectors.groupingBy(ReceiptBill::getWlbm, Collectors.summingDouble(bill -> Double.parseDouble(bill.getShsl()))));
if (!receiptBillList.isEmpty()) { if (!receiptBillList.isEmpty()) {
List<ReceiptBill2> updateList = receiptBill2Mapper.selectList( List<ReceiptBill2> updateList = receiptBill2Mapper.selectList(
new LambdaQueryWrapper<ReceiptBill2>().eq(ReceiptBill2::getDjid, receiptBillList.get(0).getDjid())); new LambdaQueryWrapper<ReceiptBill2>().eq(ReceiptBill2::getDjid, receiptBillList.get(0).getDjid()));
@ -104,6 +107,10 @@ public class ReceiptBillServiceImpl extends ServiceImpl<ReceiptBillMapper, Recei
.collect(Collectors.toList()); .collect(Collectors.toList());
} }
} }
receiptBillList= receiptBillList.stream().peek(r->{
r.setWlzs(totalQty.get(r.getWlbm()));
})
.collect(Collectors.toList());
receiptBills.setRecords(receiptBillList); receiptBills.setRecords(receiptBillList);
return CommonPage.getPage(receiptBills); return CommonPage.getPage(receiptBills);
} }

4
nlsso-server/src/main/java/org/nl/wms/schedule/EasBillSchedule.java

@ -59,7 +59,7 @@ public class EasBillSchedule {
* eas单据数据同步 * eas单据数据同步
*/ */
@Async("taskExecutor") @Async("taskExecutor")
@Scheduled(cron = "0/120 * * * * *") // @Scheduled(cron = "0/120 * * * * *")
public void getEasOutInBills() { public void getEasOutInBills() {
// 获取eas视图查询未提交的单据 // 获取eas视图查询未提交的单据
List<EasOutInBillDetail> easOutInBillDetails = easOutInBillDetailMapper.selectPageWithInventory(); List<EasOutInBillDetail> easOutInBillDetails = easOutInBillDetailMapper.selectPageWithInventory();
@ -83,7 +83,7 @@ public class EasBillSchedule {
* 定时清空单据 * 定时清空单据
*/ */
@Async("taskExecutor") @Async("taskExecutor")
@Scheduled(cron = "0/86400 * * * * *") // @Scheduled(cron = "0/86400 * * * * *")
public void autoDeleteTask() { public void autoDeleteTask() {
LocalDate threeMonthsAgo = LocalDate.now().minusMonths(3); LocalDate threeMonthsAgo = LocalDate.now().minusMonths(3);
String days = threeMonthsAgo.format(DateTimeFormatter.ofPattern("yyyy-MM-dd")); String days = threeMonthsAgo.format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));

12
nlsso-server/src/main/resources/config/application-devLocal.yml

@ -1,5 +1,5 @@
server: server:
port: 8019 port: 8011
#配置数据源 #配置数据源
spring: spring:
autoconfigure: autoconfigure:
@ -8,11 +8,17 @@ spring:
dynamic: dynamic:
primary: mysql primary: mysql
datasource: datasource:
# mysql:
# driver-class-name: net.sf.log4jdbc.sql.jdbcapi.DriverSpy
# url: jdbc:log4jdbc:mysql://${DB_HOST:127.0.0.1}:${DB_PORT:3306}/${DB_NAME:nl_sq_wms}?serverTimezone=Asia/Shanghai&characterEncoding=utf8&useSSL=false&useOldAliasMetadataBehavior=true
# username: ${DB_USER:generallu}
# password: ${DB_PWD:123456}
# type: com.alibaba.druid.pool.DruidDataSource
mysql: mysql:
driver-class-name: net.sf.log4jdbc.sql.jdbcapi.DriverSpy driver-class-name: net.sf.log4jdbc.sql.jdbcapi.DriverSpy
url: jdbc:log4jdbc:mysql://${DB_HOST:127.0.0.1}:${DB_PORT:3306}/${DB_NAME:nl_sq_wms}?serverTimezone=Asia/Shanghai&characterEncoding=utf8&useSSL=false&useOldAliasMetadataBehavior=true url: jdbc:log4jdbc:mysql://${DB_HOST:127.0.0.1}:${DB_PORT:3306}/${DB_NAME:nl_sq_wms}?serverTimezone=Asia/Shanghai&characterEncoding=utf8&useSSL=false&useOldAliasMetadataBehavior=true
username: ${DB_USER:generallu} username: ${DB_USER:root}
password: ${DB_PWD:123456} password: ${DB_PWD:NLABC&hl123}
type: com.alibaba.druid.pool.DruidDataSource type: com.alibaba.druid.pool.DruidDataSource
mysql_srm: mysql_srm:
driver-class-name: net.sf.log4jdbc.sql.jdbcapi.DriverSpy driver-class-name: net.sf.log4jdbc.sql.jdbcapi.DriverSpy

Loading…
Cancel
Save