|
|
@ -31,7 +31,6 @@ import org.nl.wms.ext.srm.WmsToSrmService; |
|
|
|
import org.springframework.beans.BeanUtils; |
|
|
|
import org.springframework.beans.factory.annotation.Qualifier; |
|
|
|
import org.springframework.scheduling.annotation.Async; |
|
|
|
import org.springframework.scheduling.annotation.Scheduled; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
import org.springframework.transaction.annotation.Propagation; |
|
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
@ -90,7 +89,6 @@ public class EasOutInBillServiceImpl extends ServiceImpl<EasOutInBillMapper, Eas |
|
|
|
private RedisUtils redisUtils; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public List<HomeBillCounts> getBillsCount() { |
|
|
|
String cacheKey = "billCounts"; |
|
|
|
//从Redis中获取缓存数据
|
|
|
@ -239,7 +237,8 @@ public class EasOutInBillServiceImpl extends ServiceImpl<EasOutInBillMapper, Eas |
|
|
|
.or() |
|
|
|
.like(EasOutInBill::getCkbm, params.getFuzzy()) |
|
|
|
.or() |
|
|
|
.like(EasOutInBill::getCjr, params.getFuzzy()) |
|
|
|
.like(EasOutInBill::getCjr, params.getFuzzy() |
|
|
|
) |
|
|
|
).orderByDesc(EasOutInBill::getCjsj) |
|
|
|
); |
|
|
|
return CommonPage.getPage(easOutInBills); |
|
|
@ -277,6 +276,16 @@ public class EasOutInBillServiceImpl extends ServiceImpl<EasOutInBillMapper, Eas |
|
|
|
return easOutInBillMapper.queryExistBills(); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 查询本地的出入库主单据 |
|
|
|
* |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
public Set<String> queryBills() { |
|
|
|
return easOutInBillMapper.queryBills(); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 查询本地未提交的出入库单据 |
|
|
|
*/ |
|
|
@ -298,17 +307,16 @@ public class EasOutInBillServiceImpl extends ServiceImpl<EasOutInBillMapper, Eas |
|
|
|
|
|
|
|
@Override |
|
|
|
public void updateOrDeleteBills(List<EasOutInBillDetail> easOutInBillDetails, List<EasOutInBillDetail> existingIds) { |
|
|
|
CompletableFuture.runAsync(() -> { |
|
|
|
try { |
|
|
|
updateBills(easOutInBillDetails, existingIds); |
|
|
|
} catch (Exception e) { |
|
|
|
log.error("异常信息:" + e); |
|
|
|
} |
|
|
|
}, pool); |
|
|
|
CompletableFuture.runAsync(() -> { |
|
|
|
//todo 检查事务是否会失效
|
|
|
|
autoDeleteBill(easOutInBillDetails, existingIds); |
|
|
|
}, pool); |
|
|
|
// CompletableFuture.runAsync(() -> {
|
|
|
|
// try {
|
|
|
|
updateBills(easOutInBillDetails, existingIds); |
|
|
|
// } catch (Exception e) {
|
|
|
|
// log.error("异常信息:" + e);
|
|
|
|
// }
|
|
|
|
// }, pool);
|
|
|
|
// CompletableFuture.runAsync(() -> {
|
|
|
|
autoDeleteBill(easOutInBillDetails, existingIds); |
|
|
|
// }, pool);
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -325,9 +333,9 @@ public class EasOutInBillServiceImpl extends ServiceImpl<EasOutInBillMapper, Eas |
|
|
|
bill.setCzsl(BigDecimal.ZERO); |
|
|
|
bill.setCzsl(BigDecimal.ZERO); |
|
|
|
bill.setKcsl(BigDecimal.ZERO); |
|
|
|
if (bill.getSl().compareTo(BigDecimal.ZERO) < 0) { |
|
|
|
bill.setSl(bill.getSl().abs()); |
|
|
|
} |
|
|
|
// if (bill.getSl().compareTo(BigDecimal.ZERO) < 0) {
|
|
|
|
// bill.setSl(bill.getSl().abs());
|
|
|
|
// }
|
|
|
|
bill.setSysl(bill.getSl()); |
|
|
|
if (bill.getDjly() == null) { |
|
|
|
bill.setCjsj(LocalDateTime.parse(bill.getCjsj(), DateTimeFormatter.ofPattern("yyyy/MM/dd HH:mm:ss")).toLocalDate().toString()); |
|
|
@ -457,6 +465,7 @@ public class EasOutInBillServiceImpl extends ServiceImpl<EasOutInBillMapper, Eas |
|
|
|
updateEntity.setCksj(entity.getCksj()); |
|
|
|
updateEntity.setLlr(entity.getLlr()); |
|
|
|
updateEntity.setTrackno(entity.getTrackno()); |
|
|
|
updateEntity.setGzhbm(entity.getGzhbm()); |
|
|
|
updateEntity.setXgsj(entity.getXgsj()); |
|
|
|
easOutInBillDetailMapper.update(updateEntity, new QueryWrapper<EasOutInBillDetail>().eq("flid", entity.getFlid())); |
|
|
|
} |
|
|
@ -516,6 +525,23 @@ public class EasOutInBillServiceImpl extends ServiceImpl<EasOutInBillMapper, Eas |
|
|
|
queryWrapper.in(EasOutInBillDetail::getFlid, filds); |
|
|
|
easOutInBillDetailMapper.delete(queryWrapper); |
|
|
|
} |
|
|
|
//查询主单据进行对比
|
|
|
|
Set<String> bills = queryBills(); |
|
|
|
Set<String> easBills = easOutInBillDetails.stream().map(EasOutInBillDetail::getDjid).collect(Collectors.toSet()); |
|
|
|
Set<String> notInExits = bills.stream() |
|
|
|
.filter(r -> !easBills.contains(r)) |
|
|
|
.collect(Collectors.toSet()); |
|
|
|
if (CollectionUtils.isNotEmpty(notInExits)) { |
|
|
|
UpdateWrapper<EasOutInBill> updateWrapper = new UpdateWrapper<EasOutInBill>() |
|
|
|
.set("update_id", SecurityUtils.getCurrentUserId()) |
|
|
|
.set("update_name", SecurityUtils.getCurrentNickName()) |
|
|
|
.set("update_time", DateUtil.format(DateUtil.beginOfDay(DateUtil.date()), "yyyy-MM-dd")) |
|
|
|
.set("djzt", "审核") |
|
|
|
.set("btbz", "扫描EAS,此单据在EAS已查询不到,或为已审核状态。") |
|
|
|
.in("djid", notInExits); |
|
|
|
easOutInBillMapper.update(null, updateWrapper); |
|
|
|
} |
|
|
|
|
|
|
|
} catch (Exception e) { |
|
|
|
log.error("定时删除源头已删除单据-autoDeleteBill接口回滚,出现异常: {}", e); |
|
|
|
} |
|
|
@ -592,6 +618,10 @@ public class EasOutInBillServiceImpl extends ServiceImpl<EasOutInBillMapper, Eas |
|
|
|
List<EasOutInBillDetailDto> billDetails = easOutInBillDetailList.stream().filter(d -> |
|
|
|
Objects.equals(d.getDjid(), b.getBillId())).collect(Collectors.toList()); |
|
|
|
if (CollectionUtils.isNotEmpty(billDetails)) { |
|
|
|
if (b.getYwlx().contains(EasBillTypeEnum.OUT.getCode())) { |
|
|
|
//只提交大于数量大于0的物料明细
|
|
|
|
billDetails = billDetails.stream().filter(r -> r.getQty().compareTo(BigDecimal.ZERO) > 0).collect(Collectors.toList()); |
|
|
|
} |
|
|
|
b.setInWhUser(SecurityUtils.getCurrentNickName() == null ? "admin" : SecurityUtils.getCurrentNickName()); |
|
|
|
b.setEntrys(billDetails); |
|
|
|
} |
|
|
@ -626,8 +656,6 @@ public class EasOutInBillServiceImpl extends ServiceImpl<EasOutInBillMapper, Eas |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
* 单个单据审核 |
|
|
|
*/ |
|
|
@ -643,7 +671,7 @@ public class EasOutInBillServiceImpl extends ServiceImpl<EasOutInBillMapper, Eas |
|
|
|
msgDto = wmsToEasService.sendWebService(billJson); |
|
|
|
if (msgDto != null) { |
|
|
|
if (msgDto.getResult() == 0) { |
|
|
|
msg = "审核失败:"+msgDto.getMsg(); |
|
|
|
msg = "审核失败:" + msgDto.getMsg(); |
|
|
|
} |
|
|
|
} |
|
|
|
} else { |
|
|
@ -652,7 +680,7 @@ public class EasOutInBillServiceImpl extends ServiceImpl<EasOutInBillMapper, Eas |
|
|
|
srmMsgDto = wmsToSrmService.sendWebPostData(billJson, 1); |
|
|
|
if (srmMsgDto != null) { |
|
|
|
if ("false".equals(srmMsgDto.getSuccess())) { |
|
|
|
msg = "审核失败:"+srmMsgDto.getMessage(); |
|
|
|
msg = "审核失败:" + srmMsgDto.getMessage(); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -674,7 +702,7 @@ public class EasOutInBillServiceImpl extends ServiceImpl<EasOutInBillMapper, Eas |
|
|
|
easData.setData(bill); |
|
|
|
String billJson = com.alibaba.fastjson.JSON.toJSONString(easData, SerializerFeature.WriteMapNullValue); |
|
|
|
wmsToEasService.sendWebService(billJson); |
|
|
|
updateBills(bill,"审核成功!"); |
|
|
|
updateBills(bill, "审核成功!"); |
|
|
|
} catch (Exception e) { |
|
|
|
log.error("推送Eas单据失败,单据号为:[" + bill.getBillId() + "]异常原因:" + e.toString()); |
|
|
|
//throw new BadRequestException(e.toString());
|
|
|
@ -691,7 +719,7 @@ public class EasOutInBillServiceImpl extends ServiceImpl<EasOutInBillMapper, Eas |
|
|
|
try { |
|
|
|
String billJson = com.alibaba.fastjson.JSON.toJSONString(bill, SerializerFeature.WriteMapNullValue); |
|
|
|
wmsToSrmService.sendWebPostData(billJson, 1); |
|
|
|
updateBills(bill,"审核成功!"); |
|
|
|
updateBills(bill, "审核成功!"); |
|
|
|
} catch (Exception e) { |
|
|
|
log.error("推送Eas单据失败,单据号为:[" + bill.getBillId() + "]异常原因:" + e.toString()); |
|
|
|
//throw new BadRequestException(e.toString());
|
|
|
@ -701,15 +729,16 @@ public class EasOutInBillServiceImpl extends ServiceImpl<EasOutInBillMapper, Eas |
|
|
|
|
|
|
|
|
|
|
|
private void updateBills(EasOutInBillDto bill, String msg) { |
|
|
|
UpdateWrapper<EasOutInBill> updateWrapper = new UpdateWrapper<EasOutInBill>().set("update_id", SecurityUtils.getCurrentUserId()).set("update_name", SecurityUtils.getCurrentNickName()).set("update_time", DateUtil.format(DateUtil.beginOfDay(DateUtil.date()), "yyyy-MM-dd")).eq("djid", bill.getBillId()); |
|
|
|
UpdateWrapper<EasOutInBill> updateWrapper = new UpdateWrapper<EasOutInBill>() |
|
|
|
.set("update_id", SecurityUtils.getCurrentUserId()) |
|
|
|
.set("update_name", SecurityUtils.getCurrentNickName()) |
|
|
|
.set("update_time", DateUtil.format(DateUtil.beginOfDay(DateUtil.date()), "yyyy-MM-dd")) |
|
|
|
.eq("djid", bill.getBillId()); |
|
|
|
if (StringUtils.isNoneBlank(msg)) { |
|
|
|
updateWrapper.set("shjg", msg); |
|
|
|
} else { |
|
|
|
updateWrapper.set("djzt", "审核"); |
|
|
|
} |
|
|
|
updateWrapper.set("update_id",SecurityUtils.getCurrentUsername()); |
|
|
|
updateWrapper.set("update_name",SecurityUtils.getCurrentNickName()); |
|
|
|
updateWrapper.set("update_time",DateUtil.format(DateUtil.beginOfDay(DateUtil.date()), "yyyy-MM-dd")); |
|
|
|
easOutInBillMapper.update(null, updateWrapper); |
|
|
|
} |
|
|
|
|
|
|
|