fix:修复

lh_dev_fifo
chenhc 7 months ago
parent 93e8319f0b
commit bc22b85acc

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

@ -1131,178 +1131,201 @@ public class ThrInvOrderServiceImpl implements ThrInvOrderService {
} }
@Resource
ThrInvOrderService thrInvOrderService;
@Override @Override
public void scanInvPhOrderGeneratePhOrder() { public void scanInvPhOrderGeneratePhOrder() {
log.info("扫描处理第三方普耗明细生成单据定时任务开始"); 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 * 1
* 2 * 2
* 3 * 3
* 4 * 4
*/ */
if (CollectionUtil.isEmpty(list)) return; // if (CollectionUtil.isEmpty(list)) return;
Map<String, List<ThrInvOrderDetail>> grouped = list.stream() // Map<String, List<ThrInvOrderDetail>> grouped = list.stream()
.collect(Collectors.groupingBy(ThrInvOrderDetail::getOrderIdFk)); // .collect(Collectors.groupingBy(ThrInvOrderDetail::getOrderIdFk));
log.info("分组的列表",grouped.toString()); // log.info("分组的列表",grouped.toString());
for (Map.Entry<String, List<ThrInvOrderDetail>> entry : grouped.entrySet()) { // for (Map.Entry<String, List<ThrInvOrderDetail>> entry : grouped.entrySet()) {
String orderIdFk = entry.getKey(); // String orderIdFk = entry.getKey();
log.info("扫描处理第三方普耗明细生成单据定时任务==orderIdFk==:[" + orderIdFk + "]"); // log.info("扫描处理第三方普耗明细生成单据定时任务==orderIdFk==:[" + orderIdFk + "]");
List<ThrInvOrderDetail> thrInvOrderDetails = entry.getValue(); // List<ThrInvOrderDetail> thrInvOrderDetails = entry.getValue();
//新单号 // //新单号
String newBillNo = gennerOrderUtils.createScOrderNo(new OrderNoTypeBean(Constant.SCAN_ORDER, "yyyyMMdd")); // String newBillNo = gennerOrderUtils.createScOrderNo(new OrderNoTypeBean(Constant.SCAN_ORDER, "yyyyMMdd"));
//通过单号获取单据信息 // //通过单号获取单据信息
QueryWrapper<ThrInvOrder> qw = new QueryWrapper<>(); // QueryWrapper<ThrInvOrder> qw = new QueryWrapper<>();
qw.eq("billNo", orderIdFk); // qw.eq("billNo", orderIdFk);
ThrInvOrder thrInvOrder = thrInvOrderMapper.selectOne(qw); // ThrInvOrder thrInvOrder = thrInvOrderMapper.selectOne(qw);
BasicBussinessTypeEntity bussinessTypeEntity = bussinessTypeService.findByAction(thrInvOrder.getBillType()); // BasicBussinessTypeEntity bussinessTypeEntity = bussinessTypeService.findByAction(thrInvOrder.getBillType());
List<ThrInvOrderDetail> addThrInvOrderDetails = new ArrayList<>(); // List<ThrInvOrderDetail> addThrInvOrderDetails = new ArrayList<>();
List<ThrInvOrderDetail> updateThrInvOrderDetails = new ArrayList<>(); // List<ThrInvOrderDetail> updateThrInvOrderDetails = new ArrayList<>();
List<Long> delThrInvOrderDetailIds = new ArrayList<>(); // List<Long> delThrInvOrderDetailIds = new ArrayList<>();
List<String> delThrCodes = new ArrayList<>(); // List<String> delThrCodes = new ArrayList<>();
if (thrInvOrder.getSourceType() == Constant.THR_INV_SF_ORDER_TYPE) {//走组套 // if (thrInvOrder.getSourceType() == Constant.THR_INV_SF_ORDER_TYPE) {//走组套
log.info("走组套"); // log.info("走组套");
thrInvOrderDetails.forEach(item -> { // thrInvOrderDetails.forEach(item -> {
Long relId = item.getRelId(); // Long relId = item.getRelId();
if (ObjectUtil.isNull(relId)) { // if (ObjectUtil.isNull(relId)) {
//通过thrCode获取到项目组套 // //通过thrCode获取到项目组套
String thrCode = item.getThrCode(); // String thrCode = item.getThrCode();
Integer count = Integer.valueOf(item.getReCount()); // Integer count = Integer.valueOf(item.getReCount());
List<BasicSkProjectDetailEntity> skProjectDetailEntityList = basicDestinyRelService.filterDestinyRelListByPId(thrCode); // List<BasicSkProjectDetailEntity> skProjectDetailEntityList = basicDestinyRelService.filterDestinyRelListByPId(thrCode);
if (CollectionUtil.isNotEmpty(skProjectDetailEntityList) && count > 0) { // if (CollectionUtil.isNotEmpty(skProjectDetailEntityList) && count > 0) {
delThrInvOrderDetailIds.add(item.getId()); // delThrInvOrderDetailIds.add(item.getId());
skProjectDetailEntityList.forEach(sk -> { // skProjectDetailEntityList.forEach(sk -> {
ThrInvOrderDetail thrInvOrderDetail = new ThrInvOrderDetail(); // ThrInvOrderDetail thrInvOrderDetail = new ThrInvOrderDetail();
BeanUtils.copyProperties(item, thrInvOrderDetail); // BeanUtils.copyProperties(item, thrInvOrderDetail);
thrInvOrderDetail.setOrderIdFk(orderIdFk); // thrInvOrderDetail.setOrderIdFk(orderIdFk);
thrInvOrderDetail.setRelId(sk.getRelId()); // thrInvOrderDetail.setRelId(sk.getRelId());
thrInvOrderDetail.setSupId(sk.getSupId() + ""); // thrInvOrderDetail.setSupId(sk.getSupId() + "");
thrInvOrderDetail.setHandleStatus(1); // thrInvOrderDetail.setHandleStatus(1);
thrInvOrderDetail.setToBillNo(newBillNo); // thrInvOrderDetail.setToBillNo(newBillNo);
//
//
Integer skCount = sk.getCount(); // Integer skCount = sk.getCount();
if (skCount != null && skCount > 0) { // if (skCount != null && skCount > 0) {
thrInvOrderDetail.setReCount(String.valueOf(skCount * count)); // thrInvOrderDetail.setReCount(String.valueOf(skCount * count));
} // }
//
addThrInvOrderDetails.add(thrInvOrderDetail); // addThrInvOrderDetails.add(thrInvOrderDetail);
delThrCodes.add(thrCode); // delThrCodes.add(thrCode);
}); // });
} else { // } else {
//
} // }
} // }
}); // });
//
} else {//不走组套 // } else {//不走组套
log.info("不走组套"); // log.info("不走组套");
String thirdSysFk = thrInvOrder.getThirdSysFk(); // String thirdSysFk = thrInvOrder.getThirdSysFk();
List<String> thrCodes = thrInvOrderDetails.stream().filter(x -> ObjectUtil.isNull(x.getRelId())) // List<String> thrCodes = thrInvOrderDetails.stream().filter(x -> ObjectUtil.isNull(x.getRelId()))
.map(ThrInvOrderDetail::getThrCode).collect(Collectors.toList()); // .map(ThrInvOrderDetail::getThrCode).collect(Collectors.toList());
if (CollectionUtil.isNotEmpty(thrCodes)) { // if (CollectionUtil.isNotEmpty(thrCodes)) {
MainIdRelIdAndProductResponse map = udiRelevanceService.selectMainIdRelIdAndProductMap(thrCodes, thirdSysFk); // MainIdRelIdAndProductResponse map = udiRelevanceService.selectMainIdRelIdAndProductMap(thrCodes, thirdSysFk);
Map<String, UdiRelevanceEntity> mainIdRelIdMap = map.getMainIdRelIdMap(); // Map<String, UdiRelevanceEntity> mainIdRelIdMap = map.getMainIdRelIdMap();
//
thrInvOrderDetails.forEach(item -> { // thrInvOrderDetails.forEach(item -> {
if (ObjectUtil.isNull(item.getRelId())) { // if (ObjectUtil.isNull(item.getRelId())) {
String thrCode = item.getThrCode(); // String thrCode = item.getThrCode();
Long relId = mainIdRelIdMap.get(thrCode).getId(); // Long relId = mainIdRelIdMap.get(thrCode).getId();
if (ObjectUtil.isNotNull(relId)) { // if (ObjectUtil.isNotNull(relId)) {
item.setRelId(relId); // item.setRelId(relId);
item.setHandleStatus(1); // item.setHandleStatus(1);
item.setToBillNo(newBillNo); // item.setToBillNo(newBillNo);
//
updateThrInvOrderDetails.add(item); // updateThrInvOrderDetails.add(item);
//校验产品是否被供应商关联 // //校验产品是否被供应商关联
CompanyProductRelevanceEntity udiRlSupEntity = udiRlSupService.selOneByRlId(relId); // CompanyProductRelevanceEntity udiRlSupEntity = udiRlSupService.selOneByRlId(relId);
if (udiRlSupEntity != null) { // if (udiRlSupEntity != null) {
item.setSupId(udiRlSupEntity.getCustomerId()); // item.setSupId(udiRlSupEntity.getCustomerId());
} // }
} else { // } 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());
thrInvOrderMapper.updateById(thrInvOrder); // //删除原来的明细
thrInvOrderDetails.forEach(item -> { // if (CollectionUtil.isNotEmpty(delThrInvOrderDetailIds)) {
item.setToBillNo(newBillNo); // thrInvOrderDetailMapper.deleteBatchIds(delThrInvOrderDetailIds);
} // }
); // //删除原来的明细
thrInvOrderDetailMapper.updateBatchById(thrInvOrderDetails); // if (CollectionUtil.isNotEmpty(delThrCodes)) {
ioOrderService.insertOrder(ioOrderEntity); // thrInvOrderDetailMapper.deleteBatchByThrCodeIds(delThrCodes);
ioOrderDetailBizService.batchInsertBizs(newOrderDetailBiz); // }
//自动处理业务单据 // //新增明细
ioAddInoutService.dealBusProcess(ioOrderEntity, bussinessTypeEntity); // 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("扫描处理第三方普耗明细生成单据定时任务结束"); log.info("扫描处理第三方普耗明细生成单据定时任务结束");
} }

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

Loading…
Cancel
Save