平潭收费出库明细

lh_dev_fifo
anthonywj 11 months ago
parent 521310d144
commit 0ec915d253

@ -109,7 +109,7 @@ public class ThrInvOrder implements Serializable {
private Integer sourceType;
/**
* 1.2.3.
* 1.2.3.,4:
*/
private Integer genStatus;

@ -55,7 +55,9 @@ import com.glxp.api.util.IntUtil;
import com.glxp.api.util.OrderNoTypeBean;
import com.glxp.api.util.udi.FilterUdiUtils;
import com.glxp.api.util.udi.UdiCalCountUtil;
import io.netty.util.internal.ThrowableUtil;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.exception.ExceptionUtils;
import org.apache.regexp.RE;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
@ -849,8 +851,6 @@ public class ThrInvOrderServiceImpl implements ThrInvOrderService {
@Override
public void scanInvSfOrderGenerateSfOrder() {
log.info("扫描处理第三方收费明细生成单据定时任务开始");
// 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));
@ -858,111 +858,125 @@ public class ThrInvOrderServiceImpl implements ThrInvOrderService {
if (CollUtil.isNotEmpty(thrInvOrders)) {
for (ThrInvOrder thrInvOrder : thrInvOrders) {
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)) continue;
//通过单号获取单据信息
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 -> {
Long relId = item.getRelId();
if (ObjectUtil.isNull(relId)) {
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(thrInvOrder.getBillNo());
thrInvOrderDetail.setRelId(sk.getRelId());
thrInvOrderDetail.setSupId(sk.getSupId() + "");
thrInvOrderDetail.setHandleStatus(1);
thrInvOrderDetail.setToBillNo(null);
Integer skCount = sk.getCount();
if (skCount != null && skCount > 0) {
thrInvOrderDetail.setReCount(String.valueOf(skCount * count));
}
addThrInvOrderDetails.add(thrInvOrderDetail);
delThrCodes.add(thrCode);
});
fullGen.getAndIncrement();
}
} else {
updateThrInvOrderDetails.add(item);
}
});
if (thrInvOrderDetails.size() == fullGen.intValue()) {
thrInvOrder.setGenStatus(2);
thrInvOrderMapper.updateById(thrInvOrder);
} else if (thrInvOrder.getGenStatus() < 1 && fullGen.intValue() > 0) {
thrInvOrder.setGenStatus(2);
try {
ThrInvOrder temp = thrInvOrderMapper.selectById(thrInvOrder.getId());
if (temp.getGenStatus() < 3) {
thrInvOrder.setGenStatus(4);
thrInvOrderMapper.updateById(thrInvOrder);
} else {
//如果该单据还在生成中则跳过
continue;
}
} 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> 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)) continue;
//通过单号获取单据信息
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(null);
updateThrInvOrderDetails.add(item);
//校验产品是否被供应商关联
CompanyProductRelevanceEntity udiRlSupEntity = udiRlSupService.selOneByRlId(relId);
if (udiRlSupEntity != null)
item.setSupId(udiRlSupEntity.getCustomerId());
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(null);
Integer skCount = sk.getCount();
if (skCount != null && skCount > 0) {
thrInvOrderDetail.setReCount(String.valueOf(skCount * count));
}
addThrInvOrderDetails.add(thrInvOrderDetail);
delThrCodes.add(thrCode);
});
fullGen.getAndIncrement();
}
} else {
updateThrInvOrderDetails.add(item);
}
});
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(null);
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);
genOrder(thrInvOrder, bussinessTypeEntity, addThrInvOrderDetails);
}
//更新明细
if (CollectionUtil.isNotEmpty(updateThrInvOrderDetails)) {
thrInvOrderDetailMapper.updateBatchById(updateThrInvOrderDetails);
genOrder(thrInvOrder, bussinessTypeEntity, updateThrInvOrderDetails);
//删除原来的明细
if (CollectionUtil.isNotEmpty(delThrInvOrderDetailIds)) {
thrInvOrderDetailMapper.deleteBatchIds(delThrInvOrderDetailIds);
}
//删除原来的明细
if (CollectionUtil.isNotEmpty(delThrCodes)) {
thrInvOrderDetailMapper.deleteBatchByThrCodeIds(delThrCodes);
}
//新增明细
if (CollectionUtil.isNotEmpty(addThrInvOrderDetails)) {
thrInvOrderDetailMapper.insertBatch(addThrInvOrderDetails);
genOrder(thrInvOrder, bussinessTypeEntity, addThrInvOrderDetails);
}
//更新明细
if (CollectionUtil.isNotEmpty(updateThrInvOrderDetails)) {
thrInvOrderDetailMapper.updateBatchById(updateThrInvOrderDetails);
genOrder(thrInvOrder, bussinessTypeEntity, updateThrInvOrderDetails);
}
} catch (Exception e) {
e.printStackTrace();
log.error("生成单据异常", ExceptionUtils.getStackTrace(e));
thrInvOrder.setGenStatus(2);
thrInvOrder.setRemark(new Date() + "出现异常");
thrInvOrderMapper.updateById(thrInvOrder);
}
}
}
}
@ -1032,6 +1046,7 @@ public class ThrInvOrderServiceImpl implements ThrInvOrderService {
}
thrInvOrderDetailMapper.updateBatchById(thrInvOrderDetails);
thrInvOrder.setToBillNo(toBillNo);
thrInvOrder.setGenStatus(3);
thrInvOrderMapper.updateById(thrInvOrder);
ioOrderService.insertOrder(ioOrderEntity);
ioOrderDetailBizService.batchInsertBizs(newOrderDetailBiz);

@ -4,7 +4,7 @@ server:
spring:
datasource:
driver-class-name: com.p6spy.engine.spy.P6SpyDriver
jdbc-url: jdbc:p6spy:mysql://127.0.0.1:3306/udi_wms_pt?allowMultiQueries=true&serverTimezone=Asia/Shanghai&useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&allowPublicKeyRetrieval=true
jdbc-url: jdbc:p6spy:mysql://127.0.0.1:3306/udi_wms_pt2?allowMultiQueries=true&serverTimezone=Asia/Shanghai&useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&allowPublicKeyRetrieval=true
username: root
password: 123456
hikari:

Loading…
Cancel
Save