feat: 增加定时扫描三方的明细表-生成单据

dev_fifo1.0
chenhc 1 year ago
parent d1743d12b4
commit 4b5be8fb3b

@ -97,10 +97,10 @@ public class TestController {
return ResultVOUtils.success(""); return ResultVOUtils.success("");
} }
@GetMapping("/test/scanInvGhOrderGenerateGhOrder") // @GetMapping("/test/scanInvSfOrderGenerateSfOrder")
public BaseResponse scanInvGhOrderGenerateGhOrder() { // public BaseResponse scanInvSfOrderGenerateSfOrder() {
thrInvOrderService.scanInvGhOrderGenerateGhOrder(); // thrInvOrderService.scanInvSfOrderGenerateSfOrder();
return ResultVOUtils.success(""); // return ResultVOUtils.success("");
} // }
} }

@ -120,6 +120,11 @@ public class ThrInvOrder implements Serializable {
private String fromCorp; private String fromCorp;
/**
*
*/
private String toBillNo;
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
} }

@ -179,6 +179,11 @@ public class ThrInvOrderDetail implements Serializable {
*/ */
private Integer handleStatus; private Integer handleStatus;
/**
*
*/
private String toBillNo;
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;

@ -111,4 +111,9 @@ public class ThrInvOrderResponse {
*/ */
private String fromCorp; private String fromCorp;
/**
*
*/
private String toBillNo;
} }

@ -451,6 +451,7 @@ public class ThrInvOrderServiceImpl implements ThrInvOrderService {
List<ThrInvOrderDetail> updateThrInvOrderDetails = new ArrayList<>(value.size()); List<ThrInvOrderDetail> updateThrInvOrderDetails = new ArrayList<>(value.size());
value.forEach( x -> { value.forEach( x -> {
x.setHandleStatus(1); x.setHandleStatus(1);
x.setToBillNo(newBillNo);
updateThrInvOrderDetails.add(x); updateThrInvOrderDetails.add(x);
}); });
@ -459,6 +460,15 @@ public class ThrInvOrderServiceImpl implements ThrInvOrderService {
thrInvOrder.setStatus(ConstantStatus.SFIO_CFMD);//已确认 thrInvOrder.setStatus(ConstantStatus.SFIO_CFMD);//已确认
thrInvOrder.setUpdateTime(new Date()); thrInvOrder.setUpdateTime(new Date());
thrInvOrder.setUpdateUser(userId + ""); 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); thrInvOrderMapper.updateById(thrInvOrder);
ioOrderDetailBizService.batchInsertBizs(newOrderDetailBiz); ioOrderDetailBizService.batchInsertBizs(newOrderDetailBiz);
@ -546,11 +556,21 @@ public class ThrInvOrderServiceImpl implements ThrInvOrderService {
List<ThrInvOrderDetail> updateThrInvOrderDetails = new ArrayList<>(value.size()); List<ThrInvOrderDetail> updateThrInvOrderDetails = new ArrayList<>(value.size());
value.forEach( x -> { value.forEach( x -> {
x.setHandleStatus(1); x.setHandleStatus(1);
x.setToBillNo(newBillNo);
updateThrInvOrderDetails.add(x); updateThrInvOrderDetails.add(x);
}); });
thrInvOrderDetailMapper.updateBatchById(updateThrInvOrderDetails); thrInvOrderDetailMapper.updateBatchById(updateThrInvOrderDetails);
ioOrderService.insertOrder(ioOrderEntity); 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.setStatus(ConstantStatus.SFIO_CFMD);//已确认
thrInvOrder.setUpdateTime(new Date()); thrInvOrder.setUpdateTime(new Date());
thrInvOrder.setUpdateUser(userId + ""); thrInvOrder.setUpdateUser(userId + "");
@ -802,36 +822,105 @@ public class ThrInvOrderServiceImpl implements ThrInvOrderService {
.collect(Collectors.groupingBy(ThrInvOrderDetail::getOrderIdFk)); .collect(Collectors.groupingBy(ThrInvOrderDetail::getOrderIdFk));
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 + "]");
List<ThrInvOrderDetail> thrInvOrderDetails = entry.getValue(); 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 -> { thrInvOrderDetails.forEach(item -> {
Long relId = item.getRelId(); Long relId = item.getRelId();
if (ObjectUtil.isNull(relId)) { if (ObjectUtil.isNull(relId)) {
String nameCode = item.getNameCode(); //通过thrCode获取到项目组套
List<BasicProductsEntity> productsEntities = udiRelevanceDao.getProductsEntitiesByNameCode(nameCode); String thrCode = item.getThrCode();
if (CollectionUtil.isNotEmpty(productsEntities)) { Integer count = Integer.valueOf(item.getReCount());
BasicProductsEntity basicProductsEntity = productsEntities.get(0); List<BasicSkProjectDetailEntity> skProjectDetailEntityList = basicDestinyRelService.filterDestinyRelListByPId(thrCode);
item.setRelId(basicProductsEntity.getId()); if (CollectionUtil.isNotEmpty(skProjectDetailEntityList) && count > 0) {
item.setHandleStatus(1); delThrInvOrderDetailIds.add(item.getId());
generatethrInvOrderDetails.add(item); 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 {
} }
} }
}); });
if (generatethrInvOrderDetails.size() >0 ){ } else {//不走组套
thrInvOrderDetailMapper.updateBatchById(generatethrInvOrderDetails);//先进行 回写已处理状态 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 -> {
QueryWrapper<ThrInvOrder> qw = new QueryWrapper<>(); if (ObjectUtil.isNull(item.getRelId())) {
qw.eq("billNo", orderIdFk); String thrCode = item.getThrCode();
ThrInvOrder thrInvOrder = thrInvOrderMapper.selectOne(qw); Long relId = mainIdRelIdMap.get(thrCode).getId();
BasicBussinessTypeEntity bussinessTypeEntity = bussinessTypeService.findByAction(thrInvOrder.getBillType()); 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);
}
if (updateThrInvOrderDetails.size() > 0 || addThrInvOrderDetails.size() > 0) {
//新单号
String newBillNo = gennerOrderUtils.createScOrderNo(new OrderNoTypeBean(Constant.SCAN_ORDER, "yyyyMMdd"));
IoOrderEntity ioOrderEntity = new IoOrderEntity(); IoOrderEntity ioOrderEntity = new IoOrderEntity();
ioOrderEntity.setBillNo(newBillNo); ioOrderEntity.setBillNo(newBillNo);
ioOrderEntity.setMainAction(thrInvOrder.getMainAction()); ioOrderEntity.setMainAction(thrInvOrder.getMainAction());
@ -852,21 +941,34 @@ public class ThrInvOrderServiceImpl implements ThrInvOrderService {
ioOrderEntity.setCreateUser(userId + ""); ioOrderEntity.setCreateUser(userId + "");
ioOrderEntity.setUpdateUser(userId + ""); ioOrderEntity.setUpdateUser(userId + "");
ioOrderEntity.setOrderType(ConstantStatus.ORDER_TYPE_SCAN);//正常单据处理 ioOrderEntity.setOrderType(ConstantStatus.ORDER_TYPE_SCAN);//正常单据处理
List<IoOrderDetailBizEntity> newOrderDetailBiz = new ArrayList<>(updateThrInvOrderDetails.size());
List<IoOrderDetailBizEntity> newOrderDetailBiz = new ArrayList<>(generatethrInvOrderDetails.size()); if (updateThrInvOrderDetails.size() > 0) {
if (!copyOrderDetailBiz(generatethrInvOrderDetails, newOrderDetailBiz, newBillNo)) { if (!copyOrderDetailBiz(updateThrInvOrderDetails, newOrderDetailBiz, newBillNo)) {
throw new JsonException("第三方收费明细自动转化单据异常"); 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); ioOrderService.insertOrder(ioOrderEntity);
ioOrderDetailBizService.batchInsertBizs(newOrderDetailBiz); ioOrderDetailBizService.batchInsertBizs(newOrderDetailBiz);
//自动处理业务单据 //自动处理业务单据
ioAddInoutService.dealBusProcess(ioOrderEntity, bussinessTypeEntity); ioAddInoutService.dealBusProcess(ioOrderEntity, bussinessTypeEntity);
} }
} }
log.info("扫描处理第三方收费明细生成单据定时任务结束"); log.info("扫描处理第三方收费明细生成单据定时任务结束");
} }
@ -885,36 +987,104 @@ public class ThrInvOrderServiceImpl implements ThrInvOrderService {
.collect(Collectors.groupingBy(ThrInvOrderDetail::getOrderIdFk)); .collect(Collectors.groupingBy(ThrInvOrderDetail::getOrderIdFk));
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 + "]");
List<ThrInvOrderDetail> thrInvOrderDetails = entry.getValue(); 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 -> { thrInvOrderDetails.forEach(item -> {
Long relId = item.getRelId(); Long relId = item.getRelId();
if (ObjectUtil.isNull(relId)) { if (ObjectUtil.isNull(relId)) {
String nameCode = item.getNameCode(); //通过thrCode获取到项目组套
List<BasicProductsEntity> productsEntities = udiRelevanceDao.getProductsEntitiesByNameCode(nameCode); String thrCode = item.getThrCode();
if (CollectionUtil.isNotEmpty(productsEntities)) { Integer count = Integer.valueOf(item.getReCount());
BasicProductsEntity basicProductsEntity = productsEntities.get(0); List<BasicSkProjectDetailEntity> skProjectDetailEntityList = basicDestinyRelService.filterDestinyRelListByPId(thrCode);
item.setRelId(basicProductsEntity.getId()); if (CollectionUtil.isNotEmpty(skProjectDetailEntityList) && count > 0) {
item.setHandleStatus(1); delThrInvOrderDetailIds.add(item.getId());
generatethrInvOrderDetails.add(item); 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 {
} }
} }
}); });
if (generatethrInvOrderDetails.size() > 0) { } else {//不走组套
thrInvOrderDetailMapper.updateBatchById(generatethrInvOrderDetails);//先进行 回写已处理状态 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 -> {
QueryWrapper<ThrInvOrder> qw = new QueryWrapper<>(); if (ObjectUtil.isNull(item.getRelId())) {
qw.eq("billNo", orderIdFk); String thrCode = item.getThrCode();
ThrInvOrder thrInvOrder = thrInvOrderMapper.selectOne(qw); Long relId = mainIdRelIdMap.get(thrCode).getId();
BasicBussinessTypeEntity bussinessTypeEntity = bussinessTypeService.findByAction(thrInvOrder.getBillType()); 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);
}
if (updateThrInvOrderDetails.size() > 0 || addThrInvOrderDetails.size() > 0) {
//新单号
String newBillNo = gennerOrderUtils.createScOrderNo(new OrderNoTypeBean(Constant.SCAN_ORDER, "yyyyMMdd"));
IoOrderEntity ioOrderEntity = new IoOrderEntity(); IoOrderEntity ioOrderEntity = new IoOrderEntity();
ioOrderEntity.setBillNo(newBillNo); ioOrderEntity.setBillNo(newBillNo);
ioOrderEntity.setMainAction(thrInvOrder.getMainAction()); ioOrderEntity.setMainAction(thrInvOrder.getMainAction());
@ -935,16 +1105,29 @@ public class ThrInvOrderServiceImpl implements ThrInvOrderService {
ioOrderEntity.setCreateUser(userId + ""); ioOrderEntity.setCreateUser(userId + "");
ioOrderEntity.setUpdateUser(userId + ""); ioOrderEntity.setUpdateUser(userId + "");
ioOrderEntity.setOrderType(ConstantStatus.ORDER_TYPE_SCAN);//正常单据处理 ioOrderEntity.setOrderType(ConstantStatus.ORDER_TYPE_SCAN);//正常单据处理
List<IoOrderDetailBizEntity> newOrderDetailBiz = new ArrayList<>(updateThrInvOrderDetails.size());
List<IoOrderDetailBizEntity> newOrderDetailBiz = new ArrayList<>(generatethrInvOrderDetails.size()); if (updateThrInvOrderDetails.size() > 0) {
if (!copyOrderDetailBiz(generatethrInvOrderDetails, newOrderDetailBiz, newBillNo)) { if (!copyOrderDetailBiz(updateThrInvOrderDetails, newOrderDetailBiz, newBillNo)) {
throw new JsonException("第三方普耗明细自动转化单据异常"); 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); ioOrderService.insertOrder(ioOrderEntity);
ioOrderDetailBizService.batchInsertBizs(newOrderDetailBiz); ioOrderDetailBizService.batchInsertBizs(newOrderDetailBiz);
//自动处理业务单据 //自动处理业务单据
ioAddInoutService.dealBusProcess(ioOrderEntity, bussinessTypeEntity); ioAddInoutService.dealBusProcess(ioOrderEntity, bussinessTypeEntity);
} }
@ -966,6 +1149,8 @@ public class ThrInvOrderServiceImpl implements ThrInvOrderService {
Map<String, List<ThrInvOrderDetail>> grouped = list.stream() Map<String, List<ThrInvOrderDetail>> grouped = list.stream()
.collect(Collectors.groupingBy(ThrInvOrderDetail::getOrderIdFk)); .collect(Collectors.groupingBy(ThrInvOrderDetail::getOrderIdFk));
for (Map.Entry<String, List<ThrInvOrderDetail>> entry : grouped.entrySet()) { for (Map.Entry<String, List<ThrInvOrderDetail>> entry : grouped.entrySet()) {
//新单号
String newBillNo = gennerOrderUtils.createScOrderNo(new OrderNoTypeBean(Constant.SCAN_ORDER, "yyyyMMdd"));
String orderIdFk = entry.getKey(); String orderIdFk = entry.getKey();
List<ThrInvOrderDetail> thrInvOrderDetails = entry.getValue(); List<ThrInvOrderDetail> thrInvOrderDetails = entry.getValue();
List<ThrInvOrderDetail> generatethrInvOrderDetails = new ArrayList<>(entry.getValue().size());//需要生成的明细 List<ThrInvOrderDetail> generatethrInvOrderDetails = new ArrayList<>(entry.getValue().size());//需要生成的明细
@ -979,6 +1164,7 @@ public class ThrInvOrderServiceImpl implements ThrInvOrderService {
BasicProductsEntity basicProductsEntity = productsEntities.get(0); BasicProductsEntity basicProductsEntity = productsEntities.get(0);
item.setRelId(basicProductsEntity.getId()); item.setRelId(basicProductsEntity.getId());
item.setHandleStatus(1); item.setHandleStatus(1);
item.setToBillNo(newBillNo);
generatethrInvOrderDetails.add(item); generatethrInvOrderDetails.add(item);
} else { } else {
@ -994,8 +1180,6 @@ public class ThrInvOrderServiceImpl implements ThrInvOrderService {
qw.eq("billNo", orderIdFk); qw.eq("billNo", orderIdFk);
ThrInvOrder thrInvOrder = thrInvOrderMapper.selectOne(qw); ThrInvOrder thrInvOrder = thrInvOrderMapper.selectOne(qw);
//新单号
String newBillNo = gennerOrderUtils.createScOrderNo(new OrderNoTypeBean(Constant.SCAN_ORDER, "yyyyMMdd"));
IoOrderEntity ioOrderEntity = new IoOrderEntity(); IoOrderEntity ioOrderEntity = new IoOrderEntity();
ioOrderEntity.setBillNo(newBillNo); ioOrderEntity.setBillNo(newBillNo);
ioOrderEntity.setMainAction(thrInvOrder.getMainAction()); ioOrderEntity.setMainAction(thrInvOrder.getMainAction());
@ -1024,6 +1208,15 @@ public class ThrInvOrderServiceImpl implements ThrInvOrderService {
throw new JsonException("第三方高耗明细自动转化单据异常"); 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); thrInvOrderDetailMapper.updateBatchById(generatethrInvOrderDetails);
ioOrderService.insertOrder(ioOrderEntity); ioOrderService.insertOrder(ioOrderEntity);
ioCodeTempDao.insertBatch(newIoCodeTemps); ioCodeTempDao.insertBatch(newIoCodeTemps);

@ -1870,4 +1870,11 @@ ALTER TABLE thr_inv_order_detail
MODIFY COLUMN `relId` bigint(0) NULL DEFAULT NULL COMMENT '物资字典主键' AFTER `cpmctymc`; MODIFY COLUMN `relId` bigint(0) NULL DEFAULT NULL COMMENT '物资字典主键' AFTER `cpmctymc`;
INSERT IGNORE INTO sys_scheduled(`id`, `cronName`, `cron`, `customerId`, `remark`) INSERT IGNORE INTO sys_scheduled(`id`, `cronName`, `cron`, `customerId`, `remark`)
VALUES (151, 'scanThrOrderGenerateOrderTask', '0 0 5 * * ?', NULL, '定时扫描三方的明细表生成单据'); VALUES (151, 'scanThrOrderGenerateOrderTask', '0 0 0/1 * * ?', NULL, '定时扫描三方的明细表生成单据');
CALL Pro_Temp_ColumnWork('thr_inv_order_detail', 'toBillNo',
' varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT ''生成的单据号''',
1);
CALL Pro_Temp_ColumnWork('thr_inv_order', 'toBillNo',
' varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT ''生成的单据号''',
1);

Loading…
Cancel
Save