Browse Source

fix: 修改试运行期间bug;

test-20240527
龚宝雄 6 months ago
parent
commit
0b7ad07d81
  1. 44
      nlsso-server/src/main/java/org/nl/wms/database/eas/service/impl/EasOutInBillDetailServiceImpl.java
  2. 9
      nlsso-server/src/main/java/org/nl/wms/database/eas/service/impl/EasOutInBillServiceImpl.java
  3. 85
      nlsso-server/src/main/java/org/nl/wms/schedule/EasBillSchedule.java

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

@ -1,6 +1,7 @@
package org.nl.wms.database.eas.service.impl;
import cn.hutool.core.date.DateUtil;
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 org.apache.commons.collections4.CollectionUtils;
@ -18,6 +19,7 @@ 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.scheduling.annotation.Async;
import org.springframework.stereotype.Service;
import cn.hutool.core.util.ObjectUtil;
import org.springframework.beans.BeanUtils;
@ -44,7 +46,6 @@ import java.util.stream.Collectors;
public class EasOutInBillDetailServiceImpl extends ServiceImpl<EasOutInBillDetailMapper, EasOutInBillDetail> implements IeasOutInBillDetailService {
@Resource
private IeasOutInBillService ieasOutInBillService;
@ -189,28 +190,32 @@ public class EasOutInBillDetailServiceImpl extends ServiceImpl<EasOutInBillDetai
@Transactional(rollbackFor = Exception.class)
public void update(List<EasOutInBillDetailVO> entityList) {
if (CollectionUtils.isNotEmpty(entityList)) {
Set<String> ids = entityList.stream().map(EasOutInBillDetailVO::getFlid).collect(Collectors.toSet());
List<EasOutInBillDetailVO> entityLists = entityList.stream().filter(r -> StringUtils.isNotEmpty(r.getKwbm())).collect(Collectors.toList());
Set<String> ids = entityLists.stream().map(EasOutInBillDetailVO::getFlid).collect(Collectors.toSet());
//需求变更为不可多次审核,否则EAS库存不准确
//ieasOutInBillService.audit(ids,false);
//单据明细为相同规格相同物料批量出入库
if (ids.size() == entityList.size() && ids.size() > 1) {
if (entityLists.size() > 1 || ids.size() > 1) {
//分录单据多选
if (ids.size() > 1) {
if (entityList.stream().anyMatch(r -> StringUtils.isEmpty(r.getKwbm()))) {
throw new BadRequestException("请检查是否有单据未分配库位");
}
entityList.forEach(r -> {
UpdateWrapper<EasOutInBillDetail> updateWrapper = new UpdateWrapper<>();
//批量待审核
updateWrapper.set("djzt", "2");
//待审核状态
updateWrapper.set("djzt", "1");
updateWrapper.eq("flid", r.getFlid());
updateWrapper.set("czsl", r.getSl());
updateWrapper.set("sysl", 0);
//库位无需扫码,填充默认库位
//updateWrapper.set("kwbm", r.getKwbm());
updateWrapper.set("update_id", SecurityUtils.getCurrentUserId());
updateWrapper.set("update_name", SecurityUtils.getCurrentNickName());
updateWrapper.set("update_time", DateUtil.format(DateUtil.beginOfDay(DateUtil.date()), "yyyy-MM-dd"));
easOutInBillDetailMapper.update(null, updateWrapper);
//ieasOutInBillService.audit(ids,false);
});
} else {
//todo 一个分录物料对应多个库位逻辑
}
} else {
//单个分录物料操作
boolean isValid = entityList.stream()
.filter(r -> StringUtils.isNotEmpty(r.getKwbm()))
.map(EasOutInBillDetailVO::getSysl)
@ -229,8 +234,8 @@ public class EasOutInBillDetailServiceImpl extends ServiceImpl<EasOutInBillDetai
throw new BadRequestException("请检查库位和数量信息");
}
UpdateWrapper<EasOutInBillDetail> updateWrapper = new UpdateWrapper<>();
//出入库操作数量达到目标数量
if (sysl.compareTo(BigDecimal.ZERO) == 0) {
//待审核
updateWrapper.set("djzt", "1");
}
updateWrapper.eq("flid", entityList.get(0).getFlid());
@ -242,7 +247,24 @@ public class EasOutInBillDetailServiceImpl extends ServiceImpl<EasOutInBillDetai
updateWrapper.set("update_time", DateUtil.format(DateUtil.beginOfDay(DateUtil.date()), "yyyy-MM-dd"));
easOutInBillDetailMapper.update(null, updateWrapper);
}
auditBills(entityList.get(0).getDjid());
}
}
/**
* 自动审核
*/
@Async("taskExecutor")
public void auditBills(String id) {
List<EasOutInBillDetail> easOutInBillDetailList = easOutInBillDetailMapper
.selectList(new LambdaQueryWrapper<EasOutInBillDetail>().eq(EasOutInBillDetail::getDjid, id));
if (!easOutInBillDetailList.isEmpty()) {
List<EasOutInBillDetail> detailList = easOutInBillDetailList.stream().filter(r -> "1".equals(r.getDjzt())).collect(Collectors.toList());
if (detailList.size() == easOutInBillDetailList.size()) {
List<String> ids = easOutInBillDetailList.stream().map(EasOutInBillDetail::getFlid).collect(Collectors.toList());
//单据审核
ieasOutInBillService.audit(ids, false);
}
}
}

9
nlsso-server/src/main/java/org/nl/wms/database/eas/service/impl/EasOutInBillServiceImpl.java

@ -500,14 +500,11 @@ public class EasOutInBillServiceImpl extends ServiceImpl<EasOutInBillMapper, Eas
}, pool);
}
} else {
//eas单据推送
easBills.addAll(srmBills);
//单个单据推送
if (CollectionUtils.isNotEmpty(easBills)) {
asyncAuditBill(easBills.get(0));
}
//srm单据推送
if (CollectionUtils.isNotEmpty(srmBills)) {
asyncAuditBill(srmBills.get(0));
}
}
}
@ -516,7 +513,7 @@ public class EasOutInBillServiceImpl extends ServiceImpl<EasOutInBillMapper, Eas
*/
public void asyncAuditBill(EasOutInBillDto bill) {
try {
if (bill.getDjly().equals("1")) {
if ("1".equals(bill.getDjly())) {
MsgDto msgDto;
EasData easData = new EasData();
easData.setData(bill);

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

@ -77,6 +77,48 @@ public class EasBillSchedule {
}
/**
* 定时清空单据
*/
@Async("taskExecutor")
@Scheduled(cron = "0/86400 * * * * *")
public void autoDeleteTask() {
LocalDate threeMonthsAgo = LocalDate.now().minusMonths(3);
String days = threeMonthsAgo.format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
//查询三个月前的数据
LambdaQueryWrapper<EasOutInBill> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.lt(EasOutInBill::getCjsj, days);
List<EasOutInBill> oldBills = easOutInBillService.list(queryWrapper);
if (CollectionUtils.isNotEmpty(oldBills)) {
Set<String> ids = oldBills.stream().map(EasOutInBill::getDjid).collect(Collectors.toSet());
if (CollectionUtils.isNotEmpty(ids)) {
easOutInBillDetailMapper.deleteDetail(ids);
}
easOutInBillDetailMapper.deleteInfo(days);
}
}
/**
* 首页信息推送
*/
@Async("taskExecutor")
//@Scheduled(cron = "0/4 * * * * *")
public void sendHomeInfoTask() {
//StopWatch stopWatch = new StopWatch();
//stopWatch.start();
CopyOnWriteArraySet<SendHomeWebSocketServer> webSocketSet =
SendHomeWebSocketServer.getWebSocketSet();
if (webSocketSet.size() > 0) {
webSocketSet.forEach(c -> {
c.sendDataToClient(easOutInBillService.getBillsCount());
});
}
//stopWatch.stop();
//System.out.println("1task-首页及头部信息推送-sendHomeInfoTask-花费时间----------------------------------------------------------------****************************************************************= totalTime = " + stopWatch.getTotalTimeMillis());
}
/**
* eas单据自动审核
*/
@ -132,52 +174,11 @@ public class EasBillSchedule {
}
}
/**
* 定时清空单据
*/
@Async("taskExecutor")
@Scheduled(cron = "0/86400 * * * * *")
public void autoDeleteTask() {
LocalDate threeMonthsAgo = LocalDate.now().minusMonths(3);
String days = threeMonthsAgo.format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
//查询三个月前的数据
LambdaQueryWrapper<EasOutInBill> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.lt(EasOutInBill::getCjsj, days);
List<EasOutInBill> oldBills = easOutInBillService.list(queryWrapper);
if (CollectionUtils.isNotEmpty(oldBills)) {
Set<String> ids = oldBills.stream().map(EasOutInBill::getDjid).collect(Collectors.toSet());
if (CollectionUtils.isNotEmpty(ids)) {
easOutInBillDetailMapper.deleteDetail(ids);
}
easOutInBillDetailMapper.deleteInfo(days);
}
}
/**
* 首页信息推送
*/
@Async("taskExecutor")
//@Scheduled(cron = "0/4 * * * * *")
public void sendHomeInfoTask() {
//StopWatch stopWatch = new StopWatch();
//stopWatch.start();
CopyOnWriteArraySet<SendHomeWebSocketServer> webSocketSet =
SendHomeWebSocketServer.getWebSocketSet();
if (webSocketSet.size() > 0) {
webSocketSet.forEach(c -> {
c.sendDataToClient(easOutInBillService.getBillsCount());
});
}
//stopWatch.stop();
//System.out.println("1task-首页及头部信息推送-sendHomeInfoTask-花费时间----------------------------------------------------------------****************************************************************= totalTime = " + stopWatch.getTotalTimeMillis());
}
/**
* 定时删除源头已删除单据
*/
@Async("taskExecutor")
//@Scheduled(cron = "0/180 * * * * *")
@Transactional(propagation = Propagation.REQUIRES_NEW, rollbackFor = Exception.class)
public void autoDeleteBill(List<EasOutInBillDetail> easOutInBillDetails, List<EasOutInBillDetail> existingIds) {
// 获取easOutInBillDetails中flid字段的集合

Loading…
Cancel
Save