//package com.kexue.skills.task;
//
//import cn.hutool.core.collection.CollectionUtil;
//import com.kexue.skills.common.Const;
//import com.kexue.skills.entity.DieselBill;
//import com.kexue.skills.entity.PurchaseOrder;
//import com.kexue.skills.entity.request.BillDetailDto;
//import com.kexue.skills.entity.request.OrderDetailDto;
//import com.kexue.skills.service.DieselBillService;
//import com.kexue.skills.service.PurchaseOrderService;
//import lombok.extern.slf4j.Slf4j;
//import org.springframework.scheduling.annotation.Scheduled;
//import org.springframework.stereotype.Component;
//import org.springframework.transaction.annotation.Transactional;
//import org.springframework.transaction.interceptor.TransactionAspectSupport;
//
//import javax.annotation.Resource;
//import java.util.List;
//import java.util.Objects;
//
///**
// * @author 维哥
// * @Description 查询所有已卖完的采购单，统计采购单的采购成本、销售成本、盈利金额、鱼损金额，更新到采购单汇总表
// * @create 2025-03-04 11:55
// */
//@Component
//@Slf4j
//public class DieselBillTask {
//
//    @Resource
//    private DieselBillService dieselBillService;
//
//    @Scheduled(cron = "0 */10 * * * *")
//    @Transactional
//    public void calculateIceBillStatistics() {
//        try {
//            log.info("采购单汇总开始...");
//            List<DieselBill> listByOrderStatus = dieselBillService.getListByOrderStatus(Const.ACCOUNT_STATUS_ACCOUNTED);
//            if (CollectionUtil.isNotEmpty(listByOrderStatus)) {
//                listByOrderStatus.forEach(bill -> {
//                    BillDetailDto dieselBillDetailById = dieselBillService.getDieselBillDetailById(bill.getId());
//                    if (Objects.nonNull(dieselBillDetailById)) {
//                        DieselBill dieselBill = dieselBillDetailById.getDieselBill();
//                        if (Objects.nonNull(dieselBill)) {
//                            dieselBillService.update(dieselBill);
//                            log.info("定时任务，更新油帐成功,orderId:{}", bill.getId());
//                        }
//                    }
//                });
//            }
//        } catch (Exception e) {
//            log.error("更新油帐汇总异常", e);
//            TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
//        }
//    }
//
//}
