diff --git a/nlsso-server/src/main/java/org/nl/wms/database/eas/dao/EasOutInBillDetail.java b/nlsso-server/src/main/java/org/nl/wms/database/eas/dao/EasOutInBillDetail.java index 3db12e4..454b1d6 100644 --- a/nlsso-server/src/main/java/org/nl/wms/database/eas/dao/EasOutInBillDetail.java +++ b/nlsso-server/src/main/java/org/nl/wms/database/eas/dao/EasOutInBillDetail.java @@ -43,6 +43,12 @@ public class EasOutInBillDetail extends Model { */ private String id; + /** + * 物料总数 + */ + @TableField(exist = false) + private Double wlzs; + /** * 单据id diff --git a/nlsso-server/src/main/java/org/nl/wms/database/eas/dao/ReceiptBill.java b/nlsso-server/src/main/java/org/nl/wms/database/eas/dao/ReceiptBill.java index 66ddc0d..bc92ac3 100644 --- a/nlsso-server/src/main/java/org/nl/wms/database/eas/dao/ReceiptBill.java +++ b/nlsso-server/src/main/java/org/nl/wms/database/eas/dao/ReceiptBill.java @@ -28,12 +28,20 @@ public class ReceiptBill extends Model { */ @TableId(value = "flid", type = IdType.NONE) private String flid; + /** + * 收货数量 + */ + private String shsl; + /** + * 物料总数 + */ + @TableField(exist = false) + private Double wlzs; /** * 审核结果 */ private String shjg; - /** * 送货单id */ @@ -102,10 +110,7 @@ public class ReceiptBill extends Model { * 本次送货数量 */ private String bcshsl; - /** - * 收货数量 - */ - private String shsl; + /** * 件数 */ diff --git a/nlsso-server/src/main/java/org/nl/wms/database/eas/dto/ReceiptBillQuery.java b/nlsso-server/src/main/java/org/nl/wms/database/eas/dto/ReceiptBillQuery.java index 25bcf1b..1afb323 100644 --- a/nlsso-server/src/main/java/org/nl/wms/database/eas/dto/ReceiptBillQuery.java +++ b/nlsso-server/src/main/java/org/nl/wms/database/eas/dto/ReceiptBillQuery.java @@ -23,6 +23,10 @@ public class ReceiptBillQuery extends BaseQuery { private String djid; + /** + * 收货数量 + */ + private String shsl; /** * 送货单号 @@ -90,10 +94,7 @@ public class ReceiptBillQuery extends BaseQuery { private String bcshsl; - /** - * 收货数量 - */ - private String shsl; + /** diff --git a/nlsso-server/src/main/java/org/nl/wms/database/eas/service/impl/EasOutInBillDetailServiceImpl.java b/nlsso-server/src/main/java/org/nl/wms/database/eas/service/impl/EasOutInBillDetailServiceImpl.java index 629d84e..e4b2012 100644 --- a/nlsso-server/src/main/java/org/nl/wms/database/eas/service/impl/EasOutInBillDetailServiceImpl.java +++ b/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; 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.QueryWrapper; 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.lang3.StringUtils; +import org.nl.common.base.CommonPage; import org.nl.common.exception.BadRequestException; import org.nl.common.utils.SecurityUtils; -import org.nl.wms.database.eas.dao.*; -import org.nl.wms.database.eas.dto.*; +import org.nl.wms.database.eas.dao.EasOutInBillDetail; +import org.nl.wms.database.eas.dao.InventoryInfo; 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 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.springframework.beans.BeanUtils; import org.springframework.scheduling.annotation.Async; 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 javax.annotation.Resource; import java.math.BigDecimal; -import java.util.*; -import java.util.concurrent.CompletableFuture; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.Set; import java.util.function.Function; import java.util.stream.Collectors; @@ -64,53 +64,64 @@ public class EasOutInBillDetailServiceImpl extends ServiceImpl easOutInBillDetailList = result.getRecords(); - List inventoryInfoList = queryInventoryInfoList(easOutInBillDetailList); + for (int i = 0; i < easOutInBillDetailList.size(); i++) { + long se = 10L; + easOutInBillDetailList.get(i).setKcsl(BigDecimal.valueOf(se + i * 10L)); + } + //计算相同物料编码的总数 + Map totalQty = easOutInBillDetailList.stream() + .collect(Collectors.groupingBy(EasOutInBillDetail::getWlbm, Collectors.summingDouble(bill -> bill.getSl().doubleValue()))); easOutInBillDetailList.forEach(bill -> { - //查询库存信息 - List 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()); - } - - //物料编码 - 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 matchedInventory = inventoryInfoList.stream() - // .filter(inventory -> Objects.equals(inventory.getZzbm(), bill.getZzbm()) - // && Objects.equals(inventory.getCkbm(), bill.getCkbm()) - // && Objects.equals(inventory.getWlbm(), bill.getWlbm()) - // && Objects.equals(inventory.getPc(), bill.getPc()) - // && Objects.equals(inventory.getTrackno(), bill.getTrackno()) - // && Objects.equals(inventory.getKwbm(), bill.getKwbm())) - // .collect(Collectors.toList()); - Optional minKcsl = matchedInventory.stream() - .filter(r -> r.getUnitno().equals(bill.getJldw())) - .min(Comparator.comparing(InventoryInfo::getKcsl)); - minKcsl.ifPresent(m -> bill.setKcsl(m.getKcsl())); + //设置物料总数 + bill.setWlzs(totalQty.get(bill.getWlbm())); }); + // List inventoryInfoList = queryInventoryInfoList(easOutInBillDetailList); + // easOutInBillDetailList.forEach(bill -> { + // //查询库存信息 + // List 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()); + // } + // + // //物料编码 + // 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 matchedInventory = inventoryInfoList.stream() + // .filter(inventory -> Objects.equals(inventory.getZzbm(), bill.getZzbm()) + // && Objects.equals(inventory.getCkbm(), bill.getCkbm()) + // && Objects.equals(inventory.getWlbm(), bill.getWlbm()) + // && Objects.equals(inventory.getPc(), bill.getPc()) + // && Objects.equals(inventory.getTrackno(), bill.getTrackno()) + // && Objects.equals(inventory.getKwbm(), bill.getKwbm())) + // .collect(Collectors.toList()); + // Optional minKcsl = matchedInventory.stream() + // .filter(r -> r.getUnitno().equals(bill.getJldw())) + // .min(Comparator.comparing(InventoryInfo::getKcsl)); + // minKcsl.ifPresent(m -> bill.setKcsl(m.getKcsl())); + // }); result.setRecords(easOutInBillDetailList); return CommonPage.getPage(result); } diff --git a/nlsso-server/src/main/java/org/nl/wms/database/eas/service/impl/ReceiptBillServiceImpl.java b/nlsso-server/src/main/java/org/nl/wms/database/eas/service/impl/ReceiptBillServiceImpl.java index da104f1..2bf2a75 100644 --- a/nlsso-server/src/main/java/org/nl/wms/database/eas/service/impl/ReceiptBillServiceImpl.java +++ b/nlsso-server/src/main/java/org/nl/wms/database/eas/service/impl/ReceiptBillServiceImpl.java @@ -81,6 +81,9 @@ public class ReceiptBillServiceImpl extends ServiceImpl pageObject = new Page<>(params.getPage(), params.getSize()); Page receiptBills = receiptBillMapper.receiptDetailPage(pageObject, params.getDjid(), params.getFuzzy()); List receiptBillList = receiptBills.getRecords(); + //计算相同物料编码的总数 + Map totalQty = receiptBillList.stream() + .collect(Collectors.groupingBy(ReceiptBill::getWlbm, Collectors.summingDouble(bill -> Double.parseDouble(bill.getShsl())))); if (!receiptBillList.isEmpty()) { List updateList = receiptBill2Mapper.selectList( new LambdaQueryWrapper().eq(ReceiptBill2::getDjid, receiptBillList.get(0).getDjid())); @@ -104,6 +107,10 @@ public class ReceiptBillServiceImpl extends ServiceImpl{ + r.setWlzs(totalQty.get(r.getWlbm())); + }) + .collect(Collectors.toList()); receiptBills.setRecords(receiptBillList); return CommonPage.getPage(receiptBills); } diff --git a/nlsso-server/src/main/java/org/nl/wms/schedule/EasBillSchedule.java b/nlsso-server/src/main/java/org/nl/wms/schedule/EasBillSchedule.java index ff0d424..bc07c92 100644 --- a/nlsso-server/src/main/java/org/nl/wms/schedule/EasBillSchedule.java +++ b/nlsso-server/src/main/java/org/nl/wms/schedule/EasBillSchedule.java @@ -59,7 +59,7 @@ public class EasBillSchedule { * eas单据数据同步 */ @Async("taskExecutor") - @Scheduled(cron = "0/120 * * * * *") + // @Scheduled(cron = "0/120 * * * * *") public void getEasOutInBills() { // 获取eas视图查询未提交的单据 List easOutInBillDetails = easOutInBillDetailMapper.selectPageWithInventory(); @@ -83,7 +83,7 @@ public class EasBillSchedule { * 定时清空单据 */ @Async("taskExecutor") - @Scheduled(cron = "0/86400 * * * * *") + // @Scheduled(cron = "0/86400 * * * * *") public void autoDeleteTask() { LocalDate threeMonthsAgo = LocalDate.now().minusMonths(3); String days = threeMonthsAgo.format(DateTimeFormatter.ofPattern("yyyy-MM-dd")); diff --git a/nlsso-server/src/main/resources/config/application-devLocal.yml b/nlsso-server/src/main/resources/config/application-devLocal.yml index a9a6541..9846d88 100644 --- a/nlsso-server/src/main/resources/config/application-devLocal.yml +++ b/nlsso-server/src/main/resources/config/application-devLocal.yml @@ -1,5 +1,5 @@ server: - port: 8019 + port: 8011 #配置数据源 spring: autoconfigure: @@ -8,11 +8,17 @@ spring: dynamic: primary: mysql 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: 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} + username: ${DB_USER:root} + password: ${DB_PWD:NLABC&hl123} type: com.alibaba.druid.pool.DruidDataSource mysql_srm: driver-class-name: net.sf.log4jdbc.sql.jdbcapi.DriverSpy