|
|
|
@ -2,9 +2,9 @@ package com.glxp.api.service.thrsys.impl;
|
|
|
|
|
|
|
|
|
|
import cn.hutool.core.collection.CollUtil;
|
|
|
|
|
import cn.hutool.core.collection.CollectionUtil;
|
|
|
|
|
import cn.hutool.core.date.DateUtil;
|
|
|
|
|
import cn.hutool.core.util.IdUtil;
|
|
|
|
|
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.github.pagehelper.PageHelper;
|
|
|
|
@ -21,7 +21,6 @@ import com.glxp.api.entity.basic.*;
|
|
|
|
|
import com.glxp.api.entity.inout.IoCodeTempEntity;
|
|
|
|
|
import com.glxp.api.entity.inout.IoOrderDetailBizEntity;
|
|
|
|
|
import com.glxp.api.entity.inout.IoOrderEntity;
|
|
|
|
|
import com.glxp.api.entity.system.SystemParamConfigEntity;
|
|
|
|
|
import com.glxp.api.entity.thrsys.*;
|
|
|
|
|
import com.glxp.api.exception.JsonException;
|
|
|
|
|
import com.glxp.api.http.ErpInvClient;
|
|
|
|
@ -36,7 +35,6 @@ import com.glxp.api.res.inv.ThrInvResultResponse;
|
|
|
|
|
import com.glxp.api.res.thrsys.ThrInvOrderResponse;
|
|
|
|
|
import com.glxp.api.service.auth.CustomerService;
|
|
|
|
|
import com.glxp.api.service.basic.IBasicBussinessTypeService;
|
|
|
|
|
import com.glxp.api.service.basic.ProductInfoService;
|
|
|
|
|
import com.glxp.api.service.basic.UdiRelevanceService;
|
|
|
|
|
import com.glxp.api.service.basic.UdiRlSupService;
|
|
|
|
|
import com.glxp.api.service.basic.impl.BasicDestinyRelService;
|
|
|
|
@ -53,7 +51,6 @@ import com.glxp.api.util.OrderNoTypeBean;
|
|
|
|
|
import com.glxp.api.util.udi.FilterUdiUtils;
|
|
|
|
|
import com.glxp.api.util.udi.UdiCalCountUtil;
|
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
import org.apache.poi.ss.formula.functions.T;
|
|
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
@ -62,6 +59,7 @@ import javax.annotation.Resource;
|
|
|
|
|
import java.text.ParseException;
|
|
|
|
|
import java.text.SimpleDateFormat;
|
|
|
|
|
import java.util.*;
|
|
|
|
|
import java.util.concurrent.atomic.AtomicInteger;
|
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -431,7 +429,7 @@ public class ThrInvOrderServiceImpl implements ThrInvOrderService {
|
|
|
|
|
ioOrderEntity.setFromType(ConstantStatus.FROM_WEBNEW);//网页新增
|
|
|
|
|
ioOrderEntity.setStatus(ConstantStatus.ORDER_STATUS_TEMP_SAVE);//草稿
|
|
|
|
|
ioOrderEntity.setDealStatus(ConstantStatus.ORDER_DEAL_DRAFT);//草稿
|
|
|
|
|
ioOrderEntity.setCorpOrderId(UUID.randomUUID()+"");//单据号
|
|
|
|
|
ioOrderEntity.setCorpOrderId(UUID.randomUUID() + "");//单据号
|
|
|
|
|
ioOrderEntity.setThrOrderIdFk(billNo);//单据号
|
|
|
|
|
ioOrderEntity.setUpdateTime(new Date());
|
|
|
|
|
ioOrderEntity.setCustomerId("110");
|
|
|
|
@ -449,7 +447,7 @@ public class ThrInvOrderServiceImpl implements ThrInvOrderService {
|
|
|
|
|
//更新三方明细列表为已处理
|
|
|
|
|
List<ThrInvOrderDetail> value = entry.getValue();
|
|
|
|
|
List<ThrInvOrderDetail> updateThrInvOrderDetails = new ArrayList<>(value.size());
|
|
|
|
|
value.forEach( x -> {
|
|
|
|
|
value.forEach(x -> {
|
|
|
|
|
x.setHandleStatus(1);
|
|
|
|
|
x.setToBillNo(newBillNo);
|
|
|
|
|
updateThrInvOrderDetails.add(x);
|
|
|
|
@ -461,7 +459,7 @@ public class ThrInvOrderServiceImpl implements ThrInvOrderService {
|
|
|
|
|
thrInvOrder.setUpdateTime(new Date());
|
|
|
|
|
thrInvOrder.setUpdateUser(userId + "");
|
|
|
|
|
|
|
|
|
|
String toBillNo = (thrInvOrder.getToBillNo()==null?"":thrInvOrder.getToBillNo()) +( "," + newBillNo);
|
|
|
|
|
String toBillNo = (thrInvOrder.getToBillNo() == null ? "" : thrInvOrder.getToBillNo()) + ("," + newBillNo);
|
|
|
|
|
// 检查字符串是否以逗号开始
|
|
|
|
|
if (toBillNo.startsWith(",")) {
|
|
|
|
|
// 使用substring()去掉第一个字符
|
|
|
|
@ -530,7 +528,7 @@ public class ThrInvOrderServiceImpl implements ThrInvOrderService {
|
|
|
|
|
ioOrderEntity.setFromType(ConstantStatus.FROM_WEBNEW);//网页新增
|
|
|
|
|
ioOrderEntity.setStatus(ConstantStatus.ORDER_STATUS_TEMP_SAVE);//草稿
|
|
|
|
|
ioOrderEntity.setDealStatus(ConstantStatus.ORDER_DEAL_DRAFT);//草稿
|
|
|
|
|
ioOrderEntity.setCorpOrderId(UUID.randomUUID()+"");//单据号
|
|
|
|
|
ioOrderEntity.setCorpOrderId(UUID.randomUUID() + "");//单据号
|
|
|
|
|
ioOrderEntity.setThrOrderIdFk(billNo);//单据号
|
|
|
|
|
ioOrderEntity.setUpdateTime(new Date());
|
|
|
|
|
ioOrderEntity.setCreateTime(new Date());
|
|
|
|
@ -554,7 +552,7 @@ public class ThrInvOrderServiceImpl implements ThrInvOrderService {
|
|
|
|
|
//更新三方明细列表为已处理
|
|
|
|
|
List<ThrInvOrderDetail> value = entry.getValue();
|
|
|
|
|
List<ThrInvOrderDetail> updateThrInvOrderDetails = new ArrayList<>(value.size());
|
|
|
|
|
value.forEach( x -> {
|
|
|
|
|
value.forEach(x -> {
|
|
|
|
|
x.setHandleStatus(1);
|
|
|
|
|
x.setToBillNo(newBillNo);
|
|
|
|
|
updateThrInvOrderDetails.add(x);
|
|
|
|
@ -563,7 +561,7 @@ public class ThrInvOrderServiceImpl implements ThrInvOrderService {
|
|
|
|
|
thrInvOrderDetailMapper.updateBatchById(updateThrInvOrderDetails);
|
|
|
|
|
ioOrderService.insertOrder(ioOrderEntity);
|
|
|
|
|
|
|
|
|
|
String toBillNo = (thrInvOrder.getToBillNo()==null?"":thrInvOrder.getToBillNo()) +( "," + newBillNo);
|
|
|
|
|
String toBillNo = (thrInvOrder.getToBillNo() == null ? "" : thrInvOrder.getToBillNo()) + ("," + newBillNo);
|
|
|
|
|
// 检查字符串是否以逗号开始
|
|
|
|
|
if (toBillNo.startsWith(",")) {
|
|
|
|
|
// 使用substring()去掉第一个字符
|
|
|
|
@ -810,166 +808,184 @@ public class ThrInvOrderServiceImpl implements ThrInvOrderService {
|
|
|
|
|
@Override
|
|
|
|
|
public void scanInvSfOrderGenerateSfOrder() {
|
|
|
|
|
log.info("扫描处理第三方收费明细生成单据定时任务开始");
|
|
|
|
|
List<ThrInvOrderDetail> list = thrInvOrderDetailMapper.selectSourceTypeList(Constant.THR_INV_SF_ORDER_TYPE);
|
|
|
|
|
/**
|
|
|
|
|
* 1、根据 外检单号 进行 分组
|
|
|
|
|
* 2、遍历不同分组 在分组的列表再次进行匹配
|
|
|
|
|
* 3、匹配到的列表 不为空 进行 新增关联的单据 插入明细操作
|
|
|
|
|
* 4、需要 回写三方的明细表 标记已处理
|
|
|
|
|
*/
|
|
|
|
|
if (CollectionUtil.isEmpty(list)) return;
|
|
|
|
|
Map<String, List<ThrInvOrderDetail>> grouped = list.stream()
|
|
|
|
|
.collect(Collectors.groupingBy(ThrInvOrderDetail::getOrderIdFk));
|
|
|
|
|
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.setId(null);
|
|
|
|
|
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();
|
|
|
|
|
// List<ThrInvOrderDetail> list = thrInvOrderDetailMapper.selectSourceTypeList(Constant.THR_INV_SF_ORDER_TYPE);
|
|
|
|
|
|
|
|
|
|
List<ThrInvOrder> thrInvOrders = thrInvOrderMapper.selectList(new LambdaQueryWrapper<ThrInvOrder>()
|
|
|
|
|
.eq(ThrInvOrder::getSourceType, Constant.THR_INV_SF_ORDER_TYPE)
|
|
|
|
|
.lt(ThrInvOrder::getGenStatus, 3));
|
|
|
|
|
|
|
|
|
|
if (CollUtil.isNotEmpty(thrInvOrders)) {
|
|
|
|
|
|
|
|
|
|
for (ThrInvOrder thrInvOrder : thrInvOrders) {
|
|
|
|
|
/**
|
|
|
|
|
* 1、根据 外检单号 进行 分组
|
|
|
|
|
* 2、遍历不同分组 在分组的列表再次进行匹配
|
|
|
|
|
* 3、匹配到的列表 不为空 进行 新增关联的单据 插入明细操作
|
|
|
|
|
* 4、需要 回写三方的明细表 标记已处理
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
List<ThrInvOrderDetail> thrInvOrderDetails = thrInvOrderDetailMapper.selectList(
|
|
|
|
|
new LambdaQueryWrapper<ThrInvOrderDetail>()
|
|
|
|
|
.and(o -> o.isNull(ThrInvOrderDetail::getHandleStatus).or().ne(ThrInvOrderDetail::getHandleStatus, 1)).
|
|
|
|
|
eq(ThrInvOrderDetail::getOrderIdFk, thrInvOrder.getBillNo())
|
|
|
|
|
);
|
|
|
|
|
if (CollectionUtil.isEmpty(thrInvOrderDetails)) return;
|
|
|
|
|
log.info("扫描处理第三方收费明细生成单据定时任务==orderIdFk==:[" + thrInvOrder.getBillNo() + "]");
|
|
|
|
|
//新单号
|
|
|
|
|
String newBillNo = gennerOrderUtils.createScOrderNo(new OrderNoTypeBean(Constant.SCAN_ORDER, "yyyyMMdd"));
|
|
|
|
|
|
|
|
|
|
//通过单号获取单据信息
|
|
|
|
|
QueryWrapper<ThrInvOrder> qw = new QueryWrapper<>();
|
|
|
|
|
qw.eq("billNo", thrInvOrder.getBillNo());
|
|
|
|
|
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("走组套");
|
|
|
|
|
AtomicInteger fullGen = new AtomicInteger();
|
|
|
|
|
thrInvOrderDetails.forEach(item -> {
|
|
|
|
|
if (ObjectUtil.isNull(item.getRelId())) {
|
|
|
|
|
Long relId = item.getRelId();
|
|
|
|
|
if (ObjectUtil.isNull(relId)) {
|
|
|
|
|
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 {
|
|
|
|
|
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.setId(null);
|
|
|
|
|
thrInvOrderDetail.setOrderIdFk(thrInvOrder.getBillNo());
|
|
|
|
|
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);
|
|
|
|
|
});
|
|
|
|
|
fullGen.getAndIncrement();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
if (thrInvOrderDetails.size() == fullGen.intValue()) {
|
|
|
|
|
thrInvOrder.setGenStatus(2);
|
|
|
|
|
thrInvOrderMapper.updateById(thrInvOrder);
|
|
|
|
|
} else if (thrInvOrder.getGenStatus() < 1 && fullGen.intValue() > 0) {
|
|
|
|
|
thrInvOrder.setGenStatus(2);
|
|
|
|
|
thrInvOrderMapper.updateById(thrInvOrder);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} 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());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//删除原来的明细
|
|
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
genOrder(newBillNo, updateThrInvOrderDetails, addThrInvOrderDetails, thrInvOrder, bussinessTypeEntity);
|
|
|
|
|
log.info("扫描处理第三方收费明细生成单据定时任务结束");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//删除原来的明细
|
|
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (updateThrInvOrderDetails.size() > 0 || addThrInvOrderDetails.size() > 0) {
|
|
|
|
|
public void genOrder(String newBillNo,
|
|
|
|
|
List<ThrInvOrderDetail> updateThrInvOrderDetails, List<ThrInvOrderDetail> addThrInvOrderDetails,
|
|
|
|
|
ThrInvOrder thrInvOrder, BasicBussinessTypeEntity bussinessTypeEntity) {
|
|
|
|
|
if (updateThrInvOrderDetails.size() > 0 || addThrInvOrderDetails.size() > 0) {
|
|
|
|
|
|
|
|
|
|
IoOrderEntity ioOrderEntity = new IoOrderEntity();
|
|
|
|
|
ioOrderEntity.setBillNo(newBillNo);
|
|
|
|
|
ioOrderEntity.setMainAction(thrInvOrder.getMainAction());
|
|
|
|
|
ioOrderEntity.setFromCorp(thrInvOrder.getFromCorp());
|
|
|
|
|
ioOrderEntity.setInvCode(thrInvOrder.getInvCode());
|
|
|
|
|
ioOrderEntity.setDeptCode(thrInvOrder.getDeptCode());
|
|
|
|
|
ioOrderEntity.setAction(thrInvOrder.getBillType());
|
|
|
|
|
IoOrderEntity ioOrderEntity = new IoOrderEntity();
|
|
|
|
|
ioOrderEntity.setBillNo(newBillNo);
|
|
|
|
|
ioOrderEntity.setMainAction(thrInvOrder.getMainAction());
|
|
|
|
|
ioOrderEntity.setFromCorp(thrInvOrder.getFromCorp());
|
|
|
|
|
ioOrderEntity.setInvCode(thrInvOrder.getInvCode());
|
|
|
|
|
ioOrderEntity.setDeptCode(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 = customerService.getUserId();
|
|
|
|
|
ioOrderEntity.setCreateUser(userId + "");
|
|
|
|
|
ioOrderEntity.setUpdateUser(userId + "");
|
|
|
|
|
ioOrderEntity.setOrderType(ConstantStatus.ORDER_TYPE_SCAN);//正常单据处理
|
|
|
|
|
List<IoOrderDetailBizEntity> newOrderDetailBiz = new ArrayList<>(updateThrInvOrderDetails.size());
|
|
|
|
|
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 = customerService.getUserId();
|
|
|
|
|
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)) {
|
|
|
|
|
throw new JsonException("第三方收费明细自动转化单据异常");
|
|
|
|
|
}
|
|
|
|
|
if (updateThrInvOrderDetails.size() > 0) {
|
|
|
|
|
if (!copyOrderDetailBiz(updateThrInvOrderDetails, newOrderDetailBiz, newBillNo)) {
|
|
|
|
|
throw new JsonException("第三方收费明细自动转化单据异常");
|
|
|
|
|
}
|
|
|
|
|
if (addThrInvOrderDetails.size() > 0) {
|
|
|
|
|
if (!copyOrderDetailBiz(addThrInvOrderDetails, newOrderDetailBiz, newBillNo)) {
|
|
|
|
|
throw new JsonException("第三方收费明细自动转化单据异常");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
String toBillNo = (thrInvOrder.getToBillNo()==null?"":thrInvOrder.getToBillNo()) +( "," + newBillNo);
|
|
|
|
|
// 检查字符串是否以逗号开始
|
|
|
|
|
if (toBillNo.startsWith(",")) {
|
|
|
|
|
// 使用substring()去掉第一个字符
|
|
|
|
|
toBillNo = toBillNo.substring(1);
|
|
|
|
|
}
|
|
|
|
|
if (addThrInvOrderDetails.size() > 0) {
|
|
|
|
|
if (!copyOrderDetailBiz(addThrInvOrderDetails, newOrderDetailBiz, newBillNo)) {
|
|
|
|
|
throw new JsonException("第三方收费明细自动转化单据异常");
|
|
|
|
|
}
|
|
|
|
|
thrInvOrder.setToBillNo(toBillNo);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
thrInvOrderMapper.updateById(thrInvOrder);
|
|
|
|
|
ioOrderService.insertOrder(ioOrderEntity);
|
|
|
|
|
ioOrderDetailBizService.batchInsertBizs(newOrderDetailBiz);
|
|
|
|
|
//自动处理业务单据
|
|
|
|
|
ioAddInoutService.dealBusProcess(ioOrderEntity, bussinessTypeEntity);
|
|
|
|
|
String toBillNo = (thrInvOrder.getToBillNo() == null ? "" : thrInvOrder.getToBillNo()) + ("," + newBillNo);
|
|
|
|
|
// 检查字符串是否以逗号开始
|
|
|
|
|
if (toBillNo.startsWith(",")) {
|
|
|
|
|
// 使用substring()去掉第一个字符
|
|
|
|
|
toBillNo = toBillNo.substring(1);
|
|
|
|
|
}
|
|
|
|
|
thrInvOrder.setToBillNo(toBillNo);
|
|
|
|
|
|
|
|
|
|
thrInvOrderMapper.updateById(thrInvOrder);
|
|
|
|
|
ioOrderService.insertOrder(ioOrderEntity);
|
|
|
|
|
ioOrderDetailBizService.batchInsertBizs(newOrderDetailBiz);
|
|
|
|
|
//自动处理业务单据
|
|
|
|
|
ioAddInoutService.dealBusProcess(ioOrderEntity, bussinessTypeEntity);
|
|
|
|
|
}
|
|
|
|
|
log.info("扫描处理第三方收费明细生成单据定时任务结束");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@ -1117,7 +1133,7 @@ public class ThrInvOrderServiceImpl implements ThrInvOrderService {
|
|
|
|
|
throw new JsonException("第三方普耗明细自动转化单据异常");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
String toBillNo = (thrInvOrder.getToBillNo()==null?"":thrInvOrder.getToBillNo()) +( "," + newBillNo);
|
|
|
|
|
String toBillNo = (thrInvOrder.getToBillNo() == null ? "" : thrInvOrder.getToBillNo()) + ("," + newBillNo);
|
|
|
|
|
// 检查字符串是否以逗号开始
|
|
|
|
|
if (toBillNo.startsWith(",")) {
|
|
|
|
|
// 使用substring()去掉第一个字符
|
|
|
|
@ -1172,7 +1188,7 @@ public class ThrInvOrderServiceImpl implements ThrInvOrderService {
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
if (generatethrInvOrderDetails.size() >0 ) {
|
|
|
|
|
if (generatethrInvOrderDetails.size() > 0) {
|
|
|
|
|
thrInvOrderDetailMapper.updateBatchById(generatethrInvOrderDetails);//先进行 回写已处理状态
|
|
|
|
|
|
|
|
|
|
//通过单号获取单据信息
|
|
|
|
@ -1208,7 +1224,7 @@ public class ThrInvOrderServiceImpl implements ThrInvOrderService {
|
|
|
|
|
throw new JsonException("第三方高耗明细自动转化单据异常");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
String toBillNo = (thrInvOrder.getToBillNo()==null?"":thrInvOrder.getToBillNo()) +( "," + newBillNo);
|
|
|
|
|
String toBillNo = (thrInvOrder.getToBillNo() == null ? "" : thrInvOrder.getToBillNo()) + ("," + newBillNo);
|
|
|
|
|
// 检查字符串是否以逗号开始
|
|
|
|
|
if (toBillNo.startsWith(",")) {
|
|
|
|
|
// 使用substring()去掉第一个字符
|
|
|
|
@ -1259,6 +1275,8 @@ public class ThrInvOrderServiceImpl implements ThrInvOrderService {
|
|
|
|
|
newBillNo) {
|
|
|
|
|
List<Long> relIds = thrInvOrderDetails.stream().filter(x -> ObjectUtil.isNotNull(x.getRelId()))
|
|
|
|
|
.map(ThrInvOrderDetail::getRelId).collect(Collectors.toList());
|
|
|
|
|
if (CollUtil.isEmpty(relIds))
|
|
|
|
|
return false;
|
|
|
|
|
List<BasicProductsEntity> basicProductsEntities = udiRelevanceDao.selectProductByRelIds(relIds);
|
|
|
|
|
if (CollectionUtil.isEmpty(basicProductsEntities)) return false;
|
|
|
|
|
Map<Long, BasicProductsEntity> relIdBasicProductsEntityMap = basicProductsEntities.stream().collect(Collectors.toMap(BasicProductsEntity::getId, x -> x));
|
|
|
|
@ -1266,11 +1284,14 @@ public class ThrInvOrderServiceImpl implements ThrInvOrderService {
|
|
|
|
|
for (int i = 0; i < thrInvOrderDetails.size(); i++) {
|
|
|
|
|
ThrInvOrderDetail thrInvOrderDetail = thrInvOrderDetails.get(i);
|
|
|
|
|
Long relId = thrInvOrderDetail.getRelId();
|
|
|
|
|
BasicProductsEntity basicProductsEntity = relIdBasicProductsEntityMap.get(relId);
|
|
|
|
|
IoOrderDetailBizEntity ioOrderDetailBizEntity = new IoOrderDetailBizEntity();
|
|
|
|
|
parameterPackag(basicProductsEntity, ioOrderDetailBizEntity, thrInvOrderDetail);
|
|
|
|
|
ioOrderDetailBizEntity.setOrderIdFk(newBillNo);
|
|
|
|
|
newOrderDetailBiz.add(ioOrderDetailBizEntity);
|
|
|
|
|
if (relId != null) {
|
|
|
|
|
BasicProductsEntity basicProductsEntity = relIdBasicProductsEntityMap.get(relId);
|
|
|
|
|
IoOrderDetailBizEntity ioOrderDetailBizEntity = new IoOrderDetailBizEntity();
|
|
|
|
|
parameterPackag(basicProductsEntity, ioOrderDetailBizEntity, thrInvOrderDetail);
|
|
|
|
|
ioOrderDetailBizEntity.setOrderIdFk(newBillNo);
|
|
|
|
|
newOrderDetailBiz.add(ioOrderDetailBizEntity);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
@ -1320,7 +1341,7 @@ public class ThrInvOrderServiceImpl implements ThrInvOrderService {
|
|
|
|
|
ioOrderDetailBizEntity.setBindRlFk(basicProductsEntity.getId());
|
|
|
|
|
ioOrderDetailBizEntity.setSupId(thrInvOrderDetail.getSupId());
|
|
|
|
|
ioOrderDetailBizEntity.setNameCode(basicProductsEntity.getNameCode());
|
|
|
|
|
ioOrderDetailBizEntity.setCount(Integer.valueOf(thrInvOrderDetail.getReCount()));
|
|
|
|
|
ioOrderDetailBizEntity.setCount(IntUtil.value(thrInvOrderDetail.getReCount()));
|
|
|
|
|
ioOrderDetailBizEntity.setBatchNo(thrInvOrderDetail.getBatchNo());
|
|
|
|
|
ioOrderDetailBizEntity.setCoName(basicProductsEntity.getCpmctymc());
|
|
|
|
|
ioOrderDetailBizEntity.setCertCode(basicProductsEntity.getZczbhhzbapzbh());
|
|
|
|
@ -1374,6 +1395,7 @@ public class ThrInvOrderServiceImpl implements ThrInvOrderService {
|
|
|
|
|
thrInvOrder.setStatus(ConstantStatus.SFIO_DRAFT);//单据状态 草稿
|
|
|
|
|
thrInvOrder.setSourceType(SourceType);//来源类型
|
|
|
|
|
thrInvOrder.setCreateTime(newDate);
|
|
|
|
|
thrInvOrder.setGenStatus(1);
|
|
|
|
|
if (thrSystemBusApiEntity != null)
|
|
|
|
|
thrInvOrder.setFromCorp(thrSystemBusApiEntity.getFromCorp());
|
|
|
|
|
thrInvOrder.setCreateUser("外部系统下载");
|
|
|
|
|