平潭收费出库明细

lh_dev_fifo
anthonywj 11 months ago
parent 521310d144
commit 0ec915d253

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

@ -55,7 +55,9 @@ import com.glxp.api.util.IntUtil;
import com.glxp.api.util.OrderNoTypeBean; import com.glxp.api.util.OrderNoTypeBean;
import com.glxp.api.util.udi.FilterUdiUtils; import com.glxp.api.util.udi.FilterUdiUtils;
import com.glxp.api.util.udi.UdiCalCountUtil; import com.glxp.api.util.udi.UdiCalCountUtil;
import io.netty.util.internal.ThrowableUtil;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.exception.ExceptionUtils;
import org.apache.regexp.RE; import org.apache.regexp.RE;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@ -849,8 +851,6 @@ public class ThrInvOrderServiceImpl implements ThrInvOrderService {
@Override @Override
public void scanInvSfOrderGenerateSfOrder() { public void scanInvSfOrderGenerateSfOrder() {
log.info("扫描处理第三方收费明细生成单据定时任务开始"); log.info("扫描处理第三方收费明细生成单据定时任务开始");
// List<ThrInvOrderDetail> list = thrInvOrderDetailMapper.selectSourceTypeList(Constant.THR_INV_SF_ORDER_TYPE);
List<ThrInvOrder> thrInvOrders = thrInvOrderMapper.selectList(new LambdaQueryWrapper<ThrInvOrder>() List<ThrInvOrder> thrInvOrders = thrInvOrderMapper.selectList(new LambdaQueryWrapper<ThrInvOrder>()
.eq(ThrInvOrder::getSourceType, Constant.THR_INV_SF_ORDER_TYPE) .eq(ThrInvOrder::getSourceType, Constant.THR_INV_SF_ORDER_TYPE)
.lt(ThrInvOrder::getGenStatus, 3)); .lt(ThrInvOrder::getGenStatus, 3));
@ -858,111 +858,125 @@ public class ThrInvOrderServiceImpl implements ThrInvOrderService {
if (CollUtil.isNotEmpty(thrInvOrders)) { if (CollUtil.isNotEmpty(thrInvOrders)) {
for (ThrInvOrder thrInvOrder : thrInvOrders) { for (ThrInvOrder thrInvOrder : thrInvOrders) {
List<ThrInvOrderDetail> thrInvOrderDetails = thrInvOrderDetailMapper.selectList( try {
new LambdaQueryWrapper<ThrInvOrderDetail>() ThrInvOrder temp = thrInvOrderMapper.selectById(thrInvOrder.getId());
.and(o -> o.isNull(ThrInvOrderDetail::getHandleStatus).or().ne(ThrInvOrderDetail::getHandleStatus, 1)). if (temp.getGenStatus() < 3) {
eq(ThrInvOrderDetail::getOrderIdFk, thrInvOrder.getBillNo()) thrInvOrder.setGenStatus(4);
);
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);
thrInvOrderMapper.updateById(thrInvOrder); thrInvOrderMapper.updateById(thrInvOrder);
} else {
//如果该单据还在生成中则跳过
continue;
} }
List<ThrInvOrderDetail> thrInvOrderDetails = thrInvOrderDetailMapper.selectList(
} else {//不走组套 new LambdaQueryWrapper<ThrInvOrderDetail>()
log.info("不走组套"); .and(o -> o.isNull(ThrInvOrderDetail::getHandleStatus).or().ne(ThrInvOrderDetail::getHandleStatus, 1)).
String thirdSysFk = thrInvOrder.getThirdSysFk(); eq(ThrInvOrderDetail::getOrderIdFk, thrInvOrder.getBillNo())
List<String> thrCodes = thrInvOrderDetails.stream().filter(x -> ObjectUtil.isNull(x.getRelId())) );
.map(ThrInvOrderDetail::getThrCode).collect(Collectors.toList()); if (CollectionUtil.isEmpty(thrInvOrderDetails)) continue;
if (CollectionUtil.isNotEmpty(thrCodes)) { //通过单号获取单据信息
MainIdRelIdAndProductResponse map = udiRelevanceService.selectMainIdRelIdAndProductMap(thrCodes, thirdSysFk); QueryWrapper<ThrInvOrder> qw = new QueryWrapper<>();
Map<String, UdiRelevanceEntity> mainIdRelIdMap = map.getMainIdRelIdMap(); 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 -> { thrInvOrderDetails.forEach(item -> {
if (ObjectUtil.isNull(item.getRelId())) { Long relId = item.getRelId();
if (ObjectUtil.isNull(relId)) {
String thrCode = item.getThrCode(); String thrCode = item.getThrCode();
Long relId = mainIdRelIdMap.get(thrCode).getId(); Integer count = Integer.valueOf(item.getReCount());
if (ObjectUtil.isNotNull(relId)) { List<BasicSkProjectDetailEntity> skProjectDetailEntityList = basicDestinyRelService.filterDestinyRelListByPId(thrCode);
item.setRelId(relId); if (CollectionUtil.isNotEmpty(skProjectDetailEntityList) && count > 0) {
item.setHandleStatus(1); delThrInvOrderDetailIds.add(item.getId());
item.setToBillNo(null); skProjectDetailEntityList.forEach(sk -> {
updateThrInvOrderDetails.add(item); ThrInvOrderDetail thrInvOrderDetail = new ThrInvOrderDetail();
//校验产品是否被供应商关联 BeanUtils.copyProperties(item, thrInvOrderDetail);
CompanyProductRelevanceEntity udiRlSupEntity = udiRlSupService.selOneByRlId(relId); thrInvOrderDetail.setId(null);
if (udiRlSupEntity != null) thrInvOrderDetail.setOrderIdFk(thrInvOrder.getBillNo());
item.setSupId(udiRlSupEntity.getCustomerId()); 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)) { if (CollectionUtil.isNotEmpty(delThrInvOrderDetailIds)) {
thrInvOrderDetailMapper.deleteBatchIds(delThrInvOrderDetailIds); thrInvOrderDetailMapper.deleteBatchIds(delThrInvOrderDetailIds);
} }
//删除原来的明细 //删除原来的明细
if (CollectionUtil.isNotEmpty(delThrCodes)) { if (CollectionUtil.isNotEmpty(delThrCodes)) {
thrInvOrderDetailMapper.deleteBatchByThrCodeIds(delThrCodes); thrInvOrderDetailMapper.deleteBatchByThrCodeIds(delThrCodes);
} }
//新增明细 //新增明细
if (CollectionUtil.isNotEmpty(addThrInvOrderDetails)) { if (CollectionUtil.isNotEmpty(addThrInvOrderDetails)) {
thrInvOrderDetailMapper.insertBatch(addThrInvOrderDetails); thrInvOrderDetailMapper.insertBatch(addThrInvOrderDetails);
genOrder(thrInvOrder, bussinessTypeEntity, addThrInvOrderDetails); genOrder(thrInvOrder, bussinessTypeEntity, addThrInvOrderDetails);
} }
//更新明细 //更新明细
if (CollectionUtil.isNotEmpty(updateThrInvOrderDetails)) { if (CollectionUtil.isNotEmpty(updateThrInvOrderDetails)) {
thrInvOrderDetailMapper.updateBatchById(updateThrInvOrderDetails); thrInvOrderDetailMapper.updateBatchById(updateThrInvOrderDetails);
genOrder(thrInvOrder, bussinessTypeEntity, 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); thrInvOrderDetailMapper.updateBatchById(thrInvOrderDetails);
thrInvOrder.setToBillNo(toBillNo); thrInvOrder.setToBillNo(toBillNo);
thrInvOrder.setGenStatus(3);
thrInvOrderMapper.updateById(thrInvOrder); thrInvOrderMapper.updateById(thrInvOrder);
ioOrderService.insertOrder(ioOrderEntity); ioOrderService.insertOrder(ioOrderEntity);
ioOrderDetailBizService.batchInsertBizs(newOrderDetailBiz); ioOrderDetailBizService.batchInsertBizs(newOrderDetailBiz);

@ -4,7 +4,7 @@ server:
spring: spring:
datasource: datasource:
driver-class-name: com.p6spy.engine.spy.P6SpyDriver 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 username: root
password: 123456 password: 123456
hikari: hikari:

Loading…
Cancel
Save