|
|
|
@ -451,6 +451,7 @@ public class ThrInvOrderServiceImpl implements ThrInvOrderService {
|
|
|
|
|
List<ThrInvOrderDetail> updateThrInvOrderDetails = new ArrayList<>(value.size());
|
|
|
|
|
value.forEach( x -> {
|
|
|
|
|
x.setHandleStatus(1);
|
|
|
|
|
x.setToBillNo(newBillNo);
|
|
|
|
|
updateThrInvOrderDetails.add(x);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
@ -459,6 +460,15 @@ public class ThrInvOrderServiceImpl implements ThrInvOrderService {
|
|
|
|
|
thrInvOrder.setStatus(ConstantStatus.SFIO_CFMD);//已确认
|
|
|
|
|
thrInvOrder.setUpdateTime(new Date());
|
|
|
|
|
thrInvOrder.setUpdateUser(userId + "");
|
|
|
|
|
|
|
|
|
|
String toBillNo = (thrInvOrder.getToBillNo()==null?"":thrInvOrder.getToBillNo() + "," + newBillNo);
|
|
|
|
|
// 检查字符串是否以逗号开始
|
|
|
|
|
if (toBillNo.startsWith(",")) {
|
|
|
|
|
// 使用substring()去掉第一个字符
|
|
|
|
|
toBillNo = toBillNo.substring(1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
thrInvOrder.setToBillNo(toBillNo);
|
|
|
|
|
thrInvOrderMapper.updateById(thrInvOrder);
|
|
|
|
|
ioOrderDetailBizService.batchInsertBizs(newOrderDetailBiz);
|
|
|
|
|
|
|
|
|
@ -546,11 +556,21 @@ public class ThrInvOrderServiceImpl implements ThrInvOrderService {
|
|
|
|
|
List<ThrInvOrderDetail> updateThrInvOrderDetails = new ArrayList<>(value.size());
|
|
|
|
|
value.forEach( x -> {
|
|
|
|
|
x.setHandleStatus(1);
|
|
|
|
|
x.setToBillNo(newBillNo);
|
|
|
|
|
updateThrInvOrderDetails.add(x);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
thrInvOrderDetailMapper.updateBatchById(updateThrInvOrderDetails);
|
|
|
|
|
ioOrderService.insertOrder(ioOrderEntity);
|
|
|
|
|
|
|
|
|
|
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());
|
|
|
|
|
thrInvOrder.setUpdateUser(userId + "");
|
|
|
|
@ -802,36 +822,105 @@ public class ThrInvOrderServiceImpl implements ThrInvOrderService {
|
|
|
|
|
.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();
|
|
|
|
|
List<ThrInvOrderDetail> generatethrInvOrderDetails = new ArrayList<>(entry.getValue().size());//需要生成的明细
|
|
|
|
|
//新单号
|
|
|
|
|
String newBillNo = gennerOrderUtils.createScOrderNo(new OrderNoTypeBean(Constant.SCAN_ORDER, "yyyyMMdd"));
|
|
|
|
|
|
|
|
|
|
thrInvOrderDetails.forEach(item -> {
|
|
|
|
|
Long relId = item.getRelId();
|
|
|
|
|
if (ObjectUtil.isNull(relId)) {
|
|
|
|
|
String nameCode = item.getNameCode();
|
|
|
|
|
List<BasicProductsEntity> productsEntities = udiRelevanceDao.getProductsEntitiesByNameCode(nameCode);
|
|
|
|
|
if (CollectionUtil.isNotEmpty(productsEntities)) {
|
|
|
|
|
BasicProductsEntity basicProductsEntity = productsEntities.get(0);
|
|
|
|
|
item.setRelId(basicProductsEntity.getId());
|
|
|
|
|
item.setHandleStatus(1);
|
|
|
|
|
generatethrInvOrderDetails.add(item);
|
|
|
|
|
} else {
|
|
|
|
|
//通过单号获取单据信息
|
|
|
|
|
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();
|
|
|
|
|
|
|
|
|
|
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 (generatethrInvOrderDetails.size() >0 ){
|
|
|
|
|
thrInvOrderDetailMapper.updateBatchById(generatethrInvOrderDetails);//先进行 回写已处理状态
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//通过单号获取单据信息
|
|
|
|
|
QueryWrapper<ThrInvOrder> qw = new QueryWrapper<>();
|
|
|
|
|
qw.eq("billNo", orderIdFk);
|
|
|
|
|
ThrInvOrder thrInvOrder = thrInvOrderMapper.selectOne(qw);
|
|
|
|
|
BasicBussinessTypeEntity bussinessTypeEntity = bussinessTypeService.findByAction(thrInvOrder.getBillType());
|
|
|
|
|
//删除原来的明细
|
|
|
|
|
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) {
|
|
|
|
|
|
|
|
|
|
//新单号
|
|
|
|
|
String newBillNo = gennerOrderUtils.createScOrderNo(new OrderNoTypeBean(Constant.SCAN_ORDER, "yyyyMMdd"));
|
|
|
|
|
IoOrderEntity ioOrderEntity = new IoOrderEntity();
|
|
|
|
|
ioOrderEntity.setBillNo(newBillNo);
|
|
|
|
|
ioOrderEntity.setMainAction(thrInvOrder.getMainAction());
|
|
|
|
@ -843,7 +932,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(thrInvOrder.getBillNo());//单据号
|
|
|
|
|
ioOrderEntity.setUpdateTime(new Date());
|
|
|
|
|
ioOrderEntity.setCreateTime(new Date());
|
|
|
|
@ -852,21 +941,34 @@ public class ThrInvOrderServiceImpl implements ThrInvOrderService {
|
|
|
|
|
ioOrderEntity.setCreateUser(userId + "");
|
|
|
|
|
ioOrderEntity.setUpdateUser(userId + "");
|
|
|
|
|
ioOrderEntity.setOrderType(ConstantStatus.ORDER_TYPE_SCAN);//正常单据处理
|
|
|
|
|
List<IoOrderDetailBizEntity> newOrderDetailBiz = new ArrayList<>(updateThrInvOrderDetails.size());
|
|
|
|
|
|
|
|
|
|
List<IoOrderDetailBizEntity> newOrderDetailBiz = new ArrayList<>(generatethrInvOrderDetails.size());
|
|
|
|
|
if (!copyOrderDetailBiz(generatethrInvOrderDetails, 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("第三方收费明细自动转化单据异常");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
thrInvOrderDetailMapper.updateBatchById(generatethrInvOrderDetails);
|
|
|
|
|
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("扫描处理第三方收费明细生成单据定时任务结束");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -885,36 +987,104 @@ public class ThrInvOrderServiceImpl implements ThrInvOrderService {
|
|
|
|
|
.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();
|
|
|
|
|
List<ThrInvOrderDetail> generatethrInvOrderDetails = new ArrayList<>(entry.getValue().size());//需要生成的明细
|
|
|
|
|
//新单号
|
|
|
|
|
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));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
thrInvOrderDetails.forEach(item -> {
|
|
|
|
|
Long relId = item.getRelId();
|
|
|
|
|
if (ObjectUtil.isNull(relId)) {
|
|
|
|
|
String nameCode = item.getNameCode();
|
|
|
|
|
List<BasicProductsEntity> productsEntities = udiRelevanceDao.getProductsEntitiesByNameCode(nameCode);
|
|
|
|
|
if (CollectionUtil.isNotEmpty(productsEntities)) {
|
|
|
|
|
BasicProductsEntity basicProductsEntity = productsEntities.get(0);
|
|
|
|
|
item.setRelId(basicProductsEntity.getId());
|
|
|
|
|
item.setHandleStatus(1);
|
|
|
|
|
generatethrInvOrderDetails.add(item);
|
|
|
|
|
} else {
|
|
|
|
|
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 (generatethrInvOrderDetails.size() > 0) {
|
|
|
|
|
thrInvOrderDetailMapper.updateBatchById(generatethrInvOrderDetails);//先进行 回写已处理状态
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//通过单号获取单据信息
|
|
|
|
|
QueryWrapper<ThrInvOrder> qw = new QueryWrapper<>();
|
|
|
|
|
qw.eq("billNo", orderIdFk);
|
|
|
|
|
ThrInvOrder thrInvOrder = thrInvOrderMapper.selectOne(qw);
|
|
|
|
|
BasicBussinessTypeEntity bussinessTypeEntity = bussinessTypeService.findByAction(thrInvOrder.getBillType());
|
|
|
|
|
//删除原来的明细
|
|
|
|
|
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) {
|
|
|
|
|
|
|
|
|
|
//新单号
|
|
|
|
|
String newBillNo = gennerOrderUtils.createScOrderNo(new OrderNoTypeBean(Constant.SCAN_ORDER, "yyyyMMdd"));
|
|
|
|
|
IoOrderEntity ioOrderEntity = new IoOrderEntity();
|
|
|
|
|
ioOrderEntity.setBillNo(newBillNo);
|
|
|
|
|
ioOrderEntity.setMainAction(thrInvOrder.getMainAction());
|
|
|
|
@ -935,21 +1105,34 @@ public class ThrInvOrderServiceImpl implements ThrInvOrderService {
|
|
|
|
|
ioOrderEntity.setCreateUser(userId + "");
|
|
|
|
|
ioOrderEntity.setUpdateUser(userId + "");
|
|
|
|
|
ioOrderEntity.setOrderType(ConstantStatus.ORDER_TYPE_SCAN);//正常单据处理
|
|
|
|
|
List<IoOrderDetailBizEntity> newOrderDetailBiz = new ArrayList<>(updateThrInvOrderDetails.size());
|
|
|
|
|
|
|
|
|
|
List<IoOrderDetailBizEntity> newOrderDetailBiz = new ArrayList<>(generatethrInvOrderDetails.size());
|
|
|
|
|
if (!copyOrderDetailBiz(generatethrInvOrderDetails, 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);
|
|
|
|
|
}
|
|
|
|
|
thrInvOrder.setToBillNo(toBillNo);
|
|
|
|
|
|
|
|
|
|
thrInvOrderDetailMapper.updateBatchById(generatethrInvOrderDetails);
|
|
|
|
|
thrInvOrderMapper.updateById(thrInvOrder);
|
|
|
|
|
ioOrderService.insertOrder(ioOrderEntity);
|
|
|
|
|
ioOrderDetailBizService.batchInsertBizs(newOrderDetailBiz);
|
|
|
|
|
|
|
|
|
|
//自动处理业务单据
|
|
|
|
|
ioAddInoutService.dealBusProcess(ioOrderEntity, bussinessTypeEntity);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
log.info("扫描处理第三方普耗明细生成单据定时任务结束");
|
|
|
|
|
log.info("扫描处理第三方普耗明细生成单据定时任务结束");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@ -966,6 +1149,8 @@ public class ThrInvOrderServiceImpl implements ThrInvOrderService {
|
|
|
|
|
Map<String, List<ThrInvOrderDetail>> grouped = list.stream()
|
|
|
|
|
.collect(Collectors.groupingBy(ThrInvOrderDetail::getOrderIdFk));
|
|
|
|
|
for (Map.Entry<String, List<ThrInvOrderDetail>> entry : grouped.entrySet()) {
|
|
|
|
|
//新单号
|
|
|
|
|
String newBillNo = gennerOrderUtils.createScOrderNo(new OrderNoTypeBean(Constant.SCAN_ORDER, "yyyyMMdd"));
|
|
|
|
|
String orderIdFk = entry.getKey();
|
|
|
|
|
List<ThrInvOrderDetail> thrInvOrderDetails = entry.getValue();
|
|
|
|
|
List<ThrInvOrderDetail> generatethrInvOrderDetails = new ArrayList<>(entry.getValue().size());//需要生成的明细
|
|
|
|
@ -979,6 +1164,7 @@ public class ThrInvOrderServiceImpl implements ThrInvOrderService {
|
|
|
|
|
BasicProductsEntity basicProductsEntity = productsEntities.get(0);
|
|
|
|
|
item.setRelId(basicProductsEntity.getId());
|
|
|
|
|
item.setHandleStatus(1);
|
|
|
|
|
item.setToBillNo(newBillNo);
|
|
|
|
|
generatethrInvOrderDetails.add(item);
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
|
@ -994,8 +1180,6 @@ public class ThrInvOrderServiceImpl implements ThrInvOrderService {
|
|
|
|
|
qw.eq("billNo", orderIdFk);
|
|
|
|
|
ThrInvOrder thrInvOrder = thrInvOrderMapper.selectOne(qw);
|
|
|
|
|
|
|
|
|
|
//新单号
|
|
|
|
|
String newBillNo = gennerOrderUtils.createScOrderNo(new OrderNoTypeBean(Constant.SCAN_ORDER, "yyyyMMdd"));
|
|
|
|
|
IoOrderEntity ioOrderEntity = new IoOrderEntity();
|
|
|
|
|
ioOrderEntity.setBillNo(newBillNo);
|
|
|
|
|
ioOrderEntity.setMainAction(thrInvOrder.getMainAction());
|
|
|
|
@ -1024,6 +1208,15 @@ public class ThrInvOrderServiceImpl implements ThrInvOrderService {
|
|
|
|
|
throw new JsonException("第三方高耗明细自动转化单据异常");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
String toBillNo = (thrInvOrder.getToBillNo()==null?"":thrInvOrder.getToBillNo() + "," + newBillNo);
|
|
|
|
|
// 检查字符串是否以逗号开始
|
|
|
|
|
if (toBillNo.startsWith(",")) {
|
|
|
|
|
// 使用substring()去掉第一个字符
|
|
|
|
|
toBillNo = toBillNo.substring(1);
|
|
|
|
|
}
|
|
|
|
|
thrInvOrder.setToBillNo(toBillNo);
|
|
|
|
|
|
|
|
|
|
thrInvOrderMapper.updateById(thrInvOrder);
|
|
|
|
|
thrInvOrderDetailMapper.updateBatchById(generatethrInvOrderDetails);
|
|
|
|
|
ioOrderService.insertOrder(ioOrderEntity);
|
|
|
|
|
ioCodeTempDao.insertBatch(newIoCodeTemps);
|
|
|
|
|