fix:修复

lh_dev_fifo
chenhc 7 months ago
parent 93e8319f0b
commit bc22b85acc

@ -33,6 +33,7 @@ public class FilterThrInvOrderRequest extends ListPageRequest {
* 123
*/
private Integer sourceType;
private Integer status;
/**
*

@ -1131,178 +1131,201 @@ public class ThrInvOrderServiceImpl implements ThrInvOrderService {
}
@Resource
ThrInvOrderService thrInvOrderService;
@Override
public void scanInvPhOrderGeneratePhOrder() {
log.info("扫描处理第三方普耗明细生成单据定时任务开始");
List<ThrInvOrderDetail> list = thrInvOrderDetailMapper.selectSourceTypeList(Constant.THR_INV_PH_ORDER_TYPE);
FilterThrInvOrderRequest filterThrInvOrderRequest = new FilterThrInvOrderRequest();
filterThrInvOrderRequest.setSourceType(Constant.THR_INV_PH_ORDER_TYPE);
filterThrInvOrderRequest.setStatus(0);
List<ThrInvOrderResponse> thrInvOrders
= thrInvOrderService.filterThrInvOrder(filterThrInvOrderRequest);
if (CollectionUtil.isEmpty(thrInvOrders)) return;
for (int i = 0; i < thrInvOrders.size(); i++) {
ThrInvOrderResponse thrInvOrderResponse = thrInvOrders.get(i);
GenerateOrderRequest generateOrderRequest = new GenerateOrderRequest();
BeanUtils.copyProperties(thrInvOrderResponse,generateOrderRequest);
generateOrderRequest.setFromCorp(thrInvOrderResponse.getInvCode());
generateOrderRequest.setAction(thrInvOrderResponse.getBillType());
generateOrderRequest.setBillNo(thrInvOrderResponse.getBillNo());
try {
thrInvOrderService.generateOrder(generateOrderRequest);
}catch (Exception e){
log.error(e.getMessage());
}
}
/**
* 1
* 2
* 3
* 4
*/
if (CollectionUtil.isEmpty(list)) return;
Map<String, List<ThrInvOrderDetail>> grouped = list.stream()
.collect(Collectors.groupingBy(ThrInvOrderDetail::getOrderIdFk));
log.info("分组的列表",grouped.toString());
for (Map.Entry<String, List<ThrInvOrderDetail>> entry : grouped.entrySet()) {
String orderIdFk = entry.getKey();
log.info("扫描处理第三方普耗明细生成单据定时任务==orderIdFk==:[" + orderIdFk + "]");
List<ThrInvOrderDetail> thrInvOrderDetails = entry.getValue();
//新单号
String newBillNo = gennerOrderUtils.createScOrderNo(new OrderNoTypeBean(Constant.SCAN_ORDER, "yyyyMMdd"));
//通过单号获取单据信息
QueryWrapper<ThrInvOrder> qw = new QueryWrapper<>();
qw.eq("billNo", orderIdFk);
ThrInvOrder thrInvOrder = thrInvOrderMapper.selectOne(qw);
BasicBussinessTypeEntity bussinessTypeEntity = bussinessTypeService.findByAction(thrInvOrder.getBillType());
List<ThrInvOrderDetail> addThrInvOrderDetails = new ArrayList<>();
List<ThrInvOrderDetail> updateThrInvOrderDetails = new ArrayList<>();
List<Long> delThrInvOrderDetailIds = new ArrayList<>();
List<String> delThrCodes = new ArrayList<>();
if (thrInvOrder.getSourceType() == Constant.THR_INV_SF_ORDER_TYPE) {//走组套
log.info("走组套");
thrInvOrderDetails.forEach(item -> {
Long relId = item.getRelId();
if (ObjectUtil.isNull(relId)) {
//通过thrCode获取到项目组套
String thrCode = item.getThrCode();
Integer count = Integer.valueOf(item.getReCount());
List<BasicSkProjectDetailEntity> skProjectDetailEntityList = basicDestinyRelService.filterDestinyRelListByPId(thrCode);
if (CollectionUtil.isNotEmpty(skProjectDetailEntityList) && count > 0) {
delThrInvOrderDetailIds.add(item.getId());
skProjectDetailEntityList.forEach(sk -> {
ThrInvOrderDetail thrInvOrderDetail = new ThrInvOrderDetail();
BeanUtils.copyProperties(item, thrInvOrderDetail);
thrInvOrderDetail.setOrderIdFk(orderIdFk);
thrInvOrderDetail.setRelId(sk.getRelId());
thrInvOrderDetail.setSupId(sk.getSupId() + "");
thrInvOrderDetail.setHandleStatus(1);
thrInvOrderDetail.setToBillNo(newBillNo);
Integer skCount = sk.getCount();
if (skCount != null && skCount > 0) {
thrInvOrderDetail.setReCount(String.valueOf(skCount * count));
}
addThrInvOrderDetails.add(thrInvOrderDetail);
delThrCodes.add(thrCode);
});
} else {
}
}
});
} else {//不走组套
log.info("不走组套");
String thirdSysFk = thrInvOrder.getThirdSysFk();
List<String> thrCodes = thrInvOrderDetails.stream().filter(x -> ObjectUtil.isNull(x.getRelId()))
.map(ThrInvOrderDetail::getThrCode).collect(Collectors.toList());
if (CollectionUtil.isNotEmpty(thrCodes)) {
MainIdRelIdAndProductResponse map = udiRelevanceService.selectMainIdRelIdAndProductMap(thrCodes, thirdSysFk);
Map<String, UdiRelevanceEntity> mainIdRelIdMap = map.getMainIdRelIdMap();
thrInvOrderDetails.forEach(item -> {
if (ObjectUtil.isNull(item.getRelId())) {
String thrCode = item.getThrCode();
Long relId = mainIdRelIdMap.get(thrCode).getId();
if (ObjectUtil.isNotNull(relId)) {
item.setRelId(relId);
item.setHandleStatus(1);
item.setToBillNo(newBillNo);
updateThrInvOrderDetails.add(item);
//校验产品是否被供应商关联
CompanyProductRelevanceEntity udiRlSupEntity = udiRlSupService.selOneByRlId(relId);
if (udiRlSupEntity != null) {
item.setSupId(udiRlSupEntity.getCustomerId());
}
} else {
}
}
});
}
}
//删除原来的明细
if (CollectionUtil.isNotEmpty(delThrInvOrderDetailIds)) {
thrInvOrderDetailMapper.deleteBatchIds(delThrInvOrderDetailIds);
}
//删除原来的明细
if (CollectionUtil.isNotEmpty(delThrCodes)) {
thrInvOrderDetailMapper.deleteBatchByThrCodeIds(delThrCodes);
}
//新增明细
if (CollectionUtil.isNotEmpty(addThrInvOrderDetails)) {
thrInvOrderDetailMapper.insertBatch(addThrInvOrderDetails);
}
//更新明细
if (CollectionUtil.isNotEmpty(updateThrInvOrderDetails)) {
thrInvOrderDetailMapper.updateBatchById(updateThrInvOrderDetails);
}
{
IoOrderEntity ioOrderEntity = new IoOrderEntity();
ioOrderEntity.setBillNo(newBillNo);
ioOrderEntity.setMainAction(thrInvOrder.getMainAction());
ioOrderEntity.setFromCorp(thrInvOrder.getFromCorp());
ioOrderEntity.setInvCode(thrInvOrder.getInvCode());
ioOrderEntity.setDeptCode(thrInvOrder.getDeptCode());
ioOrderEntity.setFromInvCode(thrInvOrder.getInvCode());
ioOrderEntity.setFromDeptCode(thrInvOrder.getDeptCode());
ioOrderEntity.setAction(thrInvOrder.getBillType());
ioOrderEntity.setFromType(ConstantStatus.FROM_WEBNEW);//网页新增
ioOrderEntity.setStatus(ConstantStatus.ORDER_STATUS_TEMP_SAVE);//草稿
ioOrderEntity.setDealStatus(ConstantStatus.ORDER_DEAL_DRAFT);//草稿
ioOrderEntity.setCorpOrderId(UUID.randomUUID() + "");//单据号
ioOrderEntity.setThrOrderIdFk(thrInvOrder.getBillNo());//单据号
ioOrderEntity.setUpdateTime(new Date());
ioOrderEntity.setCreateTime(new Date());
ioOrderEntity.setCustomerId("110");
Long userId = 1l;
ioOrderEntity.setCreateUser(userId + "");
ioOrderEntity.setUpdateUser(userId + "");
ioOrderEntity.setOrderType(ConstantStatus.ORDER_TYPE_SCAN);//正常单据处理
List<IoOrderDetailBizEntity> newOrderDetailBiz = new ArrayList<>(updateThrInvOrderDetails.size());
if (updateThrInvOrderDetails.size() > 0) {
if (!copyOrderDetailBiz(updateThrInvOrderDetails, newOrderDetailBiz, newBillNo)) {
log.info("第三方普耗明细自动转化单据异常");
}
}
if (addThrInvOrderDetails.size() > 0) {
if (!copyOrderDetailBiz(addThrInvOrderDetails, newOrderDetailBiz, newBillNo)) {
log.info("第三方普耗明细自动转化单据异常");
}
}
String toBillNo = (thrInvOrder.getToBillNo() == null ? "" : thrInvOrder.getToBillNo()) + ("," + newBillNo);
// 检查字符串是否以逗号开始
if (toBillNo.startsWith(",")) {
// 使用substring()去掉第一个字符
toBillNo = toBillNo.substring(1);
}
thrInvOrder.setToBillNo(toBillNo);
thrInvOrder.setStatus(ConstantStatus.SFIO_CFMD);//已确认
thrInvOrder.setUpdateTime(new Date());
// if (CollectionUtil.isEmpty(list)) return;
// Map<String, List<ThrInvOrderDetail>> grouped = list.stream()
// .collect(Collectors.groupingBy(ThrInvOrderDetail::getOrderIdFk));
// log.info("分组的列表",grouped.toString());
// for (Map.Entry<String, List<ThrInvOrderDetail>> entry : grouped.entrySet()) {
// String orderIdFk = entry.getKey();
// log.info("扫描处理第三方普耗明细生成单据定时任务==orderIdFk==:[" + orderIdFk + "]");
// List<ThrInvOrderDetail> thrInvOrderDetails = entry.getValue();
// //新单号
// String newBillNo = gennerOrderUtils.createScOrderNo(new OrderNoTypeBean(Constant.SCAN_ORDER, "yyyyMMdd"));
// //通过单号获取单据信息
// QueryWrapper<ThrInvOrder> qw = new QueryWrapper<>();
// qw.eq("billNo", orderIdFk);
// ThrInvOrder thrInvOrder = thrInvOrderMapper.selectOne(qw);
// BasicBussinessTypeEntity bussinessTypeEntity = bussinessTypeService.findByAction(thrInvOrder.getBillType());
// List<ThrInvOrderDetail> addThrInvOrderDetails = new ArrayList<>();
// List<ThrInvOrderDetail> updateThrInvOrderDetails = new ArrayList<>();
// List<Long> delThrInvOrderDetailIds = new ArrayList<>();
// List<String> delThrCodes = new ArrayList<>();
// if (thrInvOrder.getSourceType() == Constant.THR_INV_SF_ORDER_TYPE) {//走组套
// log.info("走组套");
// thrInvOrderDetails.forEach(item -> {
// Long relId = item.getRelId();
// if (ObjectUtil.isNull(relId)) {
// //通过thrCode获取到项目组套
// String thrCode = item.getThrCode();
// Integer count = Integer.valueOf(item.getReCount());
// List<BasicSkProjectDetailEntity> skProjectDetailEntityList = basicDestinyRelService.filterDestinyRelListByPId(thrCode);
// if (CollectionUtil.isNotEmpty(skProjectDetailEntityList) && count > 0) {
// delThrInvOrderDetailIds.add(item.getId());
// skProjectDetailEntityList.forEach(sk -> {
// ThrInvOrderDetail thrInvOrderDetail = new ThrInvOrderDetail();
// BeanUtils.copyProperties(item, thrInvOrderDetail);
// thrInvOrderDetail.setOrderIdFk(orderIdFk);
// thrInvOrderDetail.setRelId(sk.getRelId());
// thrInvOrderDetail.setSupId(sk.getSupId() + "");
// thrInvOrderDetail.setHandleStatus(1);
// thrInvOrderDetail.setToBillNo(newBillNo);
//
//
// Integer skCount = sk.getCount();
// if (skCount != null && skCount > 0) {
// thrInvOrderDetail.setReCount(String.valueOf(skCount * count));
// }
//
// addThrInvOrderDetails.add(thrInvOrderDetail);
// delThrCodes.add(thrCode);
// });
// } else {
//
// }
// }
// });
//
// } else {//不走组套
// log.info("不走组套");
// String thirdSysFk = thrInvOrder.getThirdSysFk();
// List<String> thrCodes = thrInvOrderDetails.stream().filter(x -> ObjectUtil.isNull(x.getRelId()))
// .map(ThrInvOrderDetail::getThrCode).collect(Collectors.toList());
// if (CollectionUtil.isNotEmpty(thrCodes)) {
// MainIdRelIdAndProductResponse map = udiRelevanceService.selectMainIdRelIdAndProductMap(thrCodes, thirdSysFk);
// Map<String, UdiRelevanceEntity> mainIdRelIdMap = map.getMainIdRelIdMap();
//
// thrInvOrderDetails.forEach(item -> {
// if (ObjectUtil.isNull(item.getRelId())) {
// String thrCode = item.getThrCode();
// Long relId = mainIdRelIdMap.get(thrCode).getId();
// if (ObjectUtil.isNotNull(relId)) {
// item.setRelId(relId);
// item.setHandleStatus(1);
// item.setToBillNo(newBillNo);
//
// updateThrInvOrderDetails.add(item);
// //校验产品是否被供应商关联
// CompanyProductRelevanceEntity udiRlSupEntity = udiRlSupService.selOneByRlId(relId);
// if (udiRlSupEntity != null) {
// item.setSupId(udiRlSupEntity.getCustomerId());
// }
// } else {
// }
// }
// });
// }
//
// }
thrInvOrderMapper.updateById(thrInvOrder);
thrInvOrderDetails.forEach(item -> {
item.setToBillNo(newBillNo);
}
);
thrInvOrderDetailMapper.updateBatchById(thrInvOrderDetails);
ioOrderService.insertOrder(ioOrderEntity);
ioOrderDetailBizService.batchInsertBizs(newOrderDetailBiz);
//自动处理业务单据
ioAddInoutService.dealBusProcess(ioOrderEntity, bussinessTypeEntity);
}
}
// //删除原来的明细
// if (CollectionUtil.isNotEmpty(delThrInvOrderDetailIds)) {
// thrInvOrderDetailMapper.deleteBatchIds(delThrInvOrderDetailIds);
// }
// //删除原来的明细
// if (CollectionUtil.isNotEmpty(delThrCodes)) {
// thrInvOrderDetailMapper.deleteBatchByThrCodeIds(delThrCodes);
// }
// //新增明细
// if (CollectionUtil.isNotEmpty(addThrInvOrderDetails)) {
// thrInvOrderDetailMapper.insertBatch(addThrInvOrderDetails);
// }
// //更新明细
// if (CollectionUtil.isNotEmpty(updateThrInvOrderDetails)) {
// thrInvOrderDetailMapper.updateBatchById(updateThrInvOrderDetails);
// }
//
// {
//
// IoOrderEntity ioOrderEntity = new IoOrderEntity();
// ioOrderEntity.setBillNo(newBillNo);
// ioOrderEntity.setMainAction(thrInvOrder.getMainAction());
// ioOrderEntity.setFromCorp(thrInvOrder.getFromCorp());
// ioOrderEntity.setInvCode(thrInvOrder.getInvCode());
// ioOrderEntity.setDeptCode(thrInvOrder.getDeptCode());
// ioOrderEntity.setFromInvCode(thrInvOrder.getInvCode());
// ioOrderEntity.setFromDeptCode(thrInvOrder.getDeptCode());
// ioOrderEntity.setAction(thrInvOrder.getBillType());
//
// ioOrderEntity.setFromType(ConstantStatus.FROM_WEBNEW);//网页新增
// ioOrderEntity.setStatus(ConstantStatus.ORDER_STATUS_TEMP_SAVE);//草稿
// ioOrderEntity.setDealStatus(ConstantStatus.ORDER_DEAL_DRAFT);//草稿
// ioOrderEntity.setCorpOrderId(UUID.randomUUID() + "");//单据号
// ioOrderEntity.setThrOrderIdFk(thrInvOrder.getBillNo());//单据号
// ioOrderEntity.setUpdateTime(new Date());
// ioOrderEntity.setCreateTime(new Date());
// ioOrderEntity.setCustomerId("110");
// Long userId = 1l;
// ioOrderEntity.setCreateUser(userId + "");
// ioOrderEntity.setUpdateUser(userId + "");
// ioOrderEntity.setOrderType(ConstantStatus.ORDER_TYPE_SCAN);//正常单据处理
// List<IoOrderDetailBizEntity> newOrderDetailBiz = new ArrayList<>(updateThrInvOrderDetails.size());
//
// if (updateThrInvOrderDetails.size() > 0) {
// if (!copyOrderDetailBiz(updateThrInvOrderDetails, newOrderDetailBiz, newBillNo)) {
// log.info("第三方普耗明细自动转化单据异常");
// }
// }
// if (addThrInvOrderDetails.size() > 0) {
// if (!copyOrderDetailBiz(addThrInvOrderDetails, newOrderDetailBiz, newBillNo)) {
// log.info("第三方普耗明细自动转化单据异常");
// }
// }
// String toBillNo = (thrInvOrder.getToBillNo() == null ? "" : thrInvOrder.getToBillNo()) + ("," + newBillNo);
// // 检查字符串是否以逗号开始
// if (toBillNo.startsWith(",")) {
// // 使用substring()去掉第一个字符
// toBillNo = toBillNo.substring(1);
// }
// thrInvOrder.setToBillNo(toBillNo);
// thrInvOrder.setStatus(ConstantStatus.SFIO_CFMD);//已确认
// thrInvOrder.setUpdateTime(new Date());
//
// thrInvOrderMapper.updateById(thrInvOrder);
// thrInvOrderDetails.forEach(item -> {
// item.setToBillNo(newBillNo);
// }
// );
// thrInvOrderDetailMapper.updateBatchById(thrInvOrderDetails);
// ioOrderService.insertOrder(ioOrderEntity);
// ioOrderDetailBizService.batchInsertBizs(newOrderDetailBiz);
// //自动处理业务单据
// ioAddInoutService.dealBusProcess(ioOrderEntity, bussinessTypeEntity);
// }
// }
log.info("扫描处理第三方普耗明细生成单据定时任务结束");
}

@ -30,6 +30,12 @@
<if test="sourceType != '' and sourceType != null">
AND sourceType = #{sourceType}
</if>
<if test="status != null">
AND status = #{status}
</if>
<if test="sourceType != '' and sourceType != null">
AND sourceType = #{sourceType}
</if>
<if test="chargeStartDate != null and chargeStartDate != ''">
<![CDATA[

Loading…
Cancel
Save