| | |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.toolkit.ObjectUtils; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.ruoyi.account.mapper.AccountExpenseMapper; |
| | | import com.ruoyi.account.mapper.AccountIncomeMapper; |
| | | import com.ruoyi.account.pojo.AccountExpense; |
| | | import com.ruoyi.home.mapper.HomeMapper; |
| | | import com.ruoyi.account.mapper.AccountExpenseMapper; |
| | | import com.ruoyi.approve.mapper.ApproveProcessMapper; |
| | | import com.ruoyi.approve.pojo.ApproveProcess; |
| | | import com.ruoyi.basic.mapper.CustomerMapper; |
| | | import com.ruoyi.basic.mapper.ProductMapper; |
| | | import com.ruoyi.basic.mapper.ProductModelMapper; |
| | | import com.ruoyi.basic.mapper.SupplierManageMapper; |
| | | import com.ruoyi.basic.pojo.Customer; |
| | | import com.ruoyi.basic.pojo.Product; |
| | |
| | | import com.ruoyi.dto.MapDto; |
| | | import com.ruoyi.framework.security.LoginUser; |
| | | import com.ruoyi.home.dto.*; |
| | | import com.ruoyi.home.mapper.HomeMapper; |
| | | import com.ruoyi.home.service.HomeService; |
| | | import com.ruoyi.procurementrecord.mapper.ProcurementRecordMapper; |
| | | import com.ruoyi.procurementrecord.pojo.ProcurementRecordStorage; |
| | | import com.ruoyi.procurementrecord.utils.StockUtils; |
| | | import com.ruoyi.production.dto.ProductOrderDto; |
| | | import com.ruoyi.production.dto.ProductWorkOrderDto; |
| | | import com.ruoyi.production.mapper.ProductOrderMapper; |
| | | import com.ruoyi.production.mapper.ProductProcessMapper; |
| | | import com.ruoyi.production.mapper.ProductWorkOrderMapper; |
| | | import com.ruoyi.production.mapper.ProductionProductInputMapper; |
| | | import com.ruoyi.production.mapper.ProductionProductOutputMapper; |
| | | import com.ruoyi.production.mapper.SalesLedgerProductionAccountingMapper; |
| | | import com.ruoyi.production.pojo.ProductProcess; |
| | | import com.ruoyi.production.mapper.*; |
| | | import com.ruoyi.production.pojo.ProductWorkOrder; |
| | | import com.ruoyi.project.system.domain.SysDept; |
| | | import com.ruoyi.project.system.mapper.SysDeptMapper; |
| | |
| | | |
| | | @Autowired |
| | | private ProductProcessMapper productProcessMapper; |
| | | |
| | | |
| | | @Autowired |
| | | private AccountExpenseMapper accountExpenseMapper; |
| | | |
| | |
| | | @Override |
| | | public HomeSummaryDto summaryStatistics() { |
| | | HomeSummaryDto dto = new HomeSummaryDto(); |
| | | LocalDate now = LocalDate.now(); |
| | | YearMonth currentMonth = YearMonth.from(now); |
| | | YearMonth prevMonth = currentMonth.minusMonths(1); |
| | | |
| | | LocalDateTime currentMonthEnd = currentMonth.atEndOfMonth().atTime(23, 59, 59); |
| | | LocalDateTime prevMonthEnd = prevMonth.atEndOfMonth().atTime(23, 59, 59); |
| | | |
| | | // 总工作人员 |
| | | Long currentStaff = countStaff(currentMonthEnd); |
| | | Long prevStaff = countStaff(prevMonthEnd); |
| | | Long currentStaff = 0L; |
| | | dto.setTotalStaff(currentStaff); |
| | | dto.setStaffGrowthRate(calculateMoM(currentStaff, prevStaff)); |
| | | |
| | | // 总客户数 |
| | | Long currentCustomers = countCustomers(currentMonthEnd); |
| | | Long prevCustomers = countCustomers(prevMonthEnd); |
| | | Long currentCustomers = customerMapper.selectCount(null); |
| | | dto.setTotalCustomer(currentCustomers); |
| | | dto.setCustomerGrowthRate(calculateMoM(currentCustomers, prevCustomers)); |
| | | |
| | | // 总供应商数 |
| | | Long currentSuppliers = countSuppliers(currentMonthEnd); |
| | | Long prevSuppliers = countSuppliers(prevMonthEnd); |
| | | Long currentSuppliers = supplierManageMapper.selectCount(null); |
| | | dto.setTotalSupplier(currentSuppliers); |
| | | dto.setSupplierGrowthRate(calculateMoM(currentSuppliers, prevSuppliers)); |
| | | |
| | | return dto; |
| | | } |
| | | |
| | | private Long countStaff(LocalDateTime dateTime) { |
| | | Long staffCountItem = staffOnJobMapper.selectCount(new LambdaQueryWrapper<StaffOnJob>() |
| | | .isNotNull(StaffOnJob::getStaffState) |
| | | .eq(StaffOnJob::getStaffState, 1) |
| | | .le(StaffOnJob::getCreateTime, dateTime)); |
| | | return staffCountItem; |
| | | } |
| | | |
| | | private Long countCustomers(LocalDateTime dateTime) { |
| | | return customerMapper.selectCount(new LambdaQueryWrapper<Customer>() |
| | | .le(Customer::getMaintenanceTime, dateTime.toLocalDate())); |
| | | } |
| | | |
| | | private Long countSuppliers(LocalDateTime dateTime) { |
| | | return supplierManageMapper.selectCount(new LambdaQueryWrapper<SupplierManage>() |
| | | .le(SupplierManage::getCreateTime, dateTime)); |
| | | } |
| | | |
| | | private String calculateMoM(Number current, Number prev) { |
| | | BigDecimal curVal = new BigDecimal(current.toString()); |
| | | BigDecimal prevVal = new BigDecimal(prev.toString()); |
| | | if (prevVal.compareTo(BigDecimal.ZERO) == 0) { |
| | | return curVal.compareTo(BigDecimal.ZERO) > 0 ? "100.00" : "0.00"; |
| | | } |
| | | return curVal.subtract(prevVal) |
| | | .divide(prevVal, 4, RoundingMode.HALF_UP) |
| | | .multiply(new BigDecimal("100")) |
| | | .setScale(2, RoundingMode.HALF_UP) |
| | | .toString(); |
| | | } |
| | | |
| | | @Override |
| | | public List<SupplierPurchaseRankingDto> supplierPurchaseRanking(Integer type) { |
| | |
| | | .collect(Collectors.groupingBy(QualityInspect::getCheckResult)); |
| | | List<QualityInspect> qualityInspects = groupedByCheckResult.get("不合格"); |
| | | if (ObjectUtils.isNull(qualityInspects) || qualityInspects.size() == 0) { |
| | | return null; |
| | | return dto; |
| | | } |
| | | // 4. 处理图表项 (Item) |
| | | List<QualityStatisticsItem> itemList = new ArrayList<>(); |