liyong
2026-04-28 2c51e2bac7e271f6bd1a7da060e4ffd327d5a8d2
src/main/java/com/ruoyi/production/service/impl/ProductionProductMainServiceImpl.java
@@ -48,12 +48,15 @@
import java.util.Objects;
import java.util.stream.Collectors;
import static cn.hutool.core.date.LocalDateTimeUtil.between;
@Service
@AllArgsConstructor
@Transactional(rollbackFor = Exception.class)
public class ProductionProductMainServiceImpl extends ServiceImpl<ProductionProductMainMapper, ProductionProductMain> implements ProductionProductMainService {
    private final SalesLedgerMapper salesLedgerMapper;
    private final ProductionMachineRecordMapper productionMachineRecordMapper;
    private IQualityInspectService qualityInspectService;
    private ProductionProductMainMapper productionProductMainMapper;
@@ -368,10 +371,14 @@
            /*添加生产核算        区分工序是计件还是计时*/
            BigDecimal workHours = productProcess.getSalaryQuota();
            ProductWorkOrder productWorkOrder = productWorkOrderMapper.selectById(productionProductMain.getWorkOrderId());
            String userIds = productWorkOrder.getUserIds();
            if (ObjectUtils.isNotEmpty(userIds)) {
                for (String s : userIds.split(",")) {
            List<ProductionMachineRecord> productionMachineRecords = productionMachineRecordMapper.selectList(Wrappers.<ProductionMachineRecord>lambdaQuery().eq(ProductionMachineRecord::getWorkOrderId, productionProductMain.getWorkOrderId()));
            if (ObjectUtils.isNotEmpty(productionMachineRecords)) {
                for (ProductionMachineRecord productionMachineRecord : productionMachineRecords) {
                    for (String s : productionMachineRecord.getOperatorId().split(",")) {
                        Long minutes = 0L;
                        if (productionMachineRecord.getMachineStartTime() != null) {
                            minutes = between(productionMachineRecord.getMachineStartTime(), LocalDateTime.now()).toMinutes();
                        }
                    SalesLedgerProductionAccounting salesLedgerProductionAccounting = SalesLedgerProductionAccounting.builder()
                            .productMainId(productionProductMain.getId())
                            .schedulingUserId(Long.parseLong(s))
@@ -381,9 +388,13 @@
                            .process(productProcess.getName())
                            .schedulingDate(LocalDate.now())
                            .tenantId(productionProductOutput.getTenantId())
                                .deviceId(productionMachineRecord.getMachineId())
                                .workHour(minutes)
                            .build();
                    salesLedgerProductionAccountingMapper.insert(salesLedgerProductionAccounting);
                }
                }
            }
        }