| | |
| | | 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; |
| | | |
| | |
| | | |
| | | /*添加生产核算 区分工序是计件还是计时*/ |
| | | BigDecimal workHours = productProcess.getSalaryQuota(); |
| | | ProductWorkOrder productWorkOrder = productWorkOrderMapper.selectById(productionProductMain.getWorkOrderId()); |
| | | String userIds = productWorkOrder.getUserIds(); |
| | | if (ObjectUtils.isNotEmpty(userIds)) { |
| | | for (String s : userIds.split(",")) { |
| | | SalesLedgerProductionAccounting salesLedgerProductionAccounting = SalesLedgerProductionAccounting.builder() |
| | | .productMainId(productionProductMain.getId()) |
| | | .schedulingUserId(Long.parseLong(s)) |
| | | .schedulingUserName(userMapper.selectUserById(Long.parseLong(s)).getNickName()) |
| | | .finishedNum(productQty) |
| | | .workHours(workHours) |
| | | .process(productProcess.getName()) |
| | | .schedulingDate(LocalDate.now()) |
| | | .tenantId(productionProductOutput.getTenantId()) |
| | | .build(); |
| | | salesLedgerProductionAccountingMapper.insert(salesLedgerProductionAccounting); |
| | | 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)) |
| | | .schedulingUserName(userMapper.selectUserById(Long.parseLong(s)).getNickName()) |
| | | .finishedNum(productQty) |
| | | .workHours(workHours) |
| | | .process(productProcess.getName()) |
| | | .schedulingDate(LocalDate.now()) |
| | | .tenantId(productionProductOutput.getTenantId()) |
| | | .deviceId(productionMachineRecord.getMachineId()) |
| | | .workHour(minutes) |
| | | .build(); |
| | | salesLedgerProductionAccountingMapper.insert(salesLedgerProductionAccounting); |
| | | } |
| | | |
| | | } |
| | | } |
| | | } |