| | |
| | | @Excel(name = "å·¥æ¶å®é¢") |
| | | private BigDecimal workHours; |
| | | |
| | | @Excel(name = "åå·¥èµ") |
| | | private BigDecimal originalWages; |
| | | |
| | | @Excel(name = "ä¿®æ£å·¥èµ") |
| | | private BigDecimal adjustAmount; |
| | | |
| | | @Excel(name = "å·¥èµ") |
| | | private BigDecimal wages; |
| | | } |
| | |
| | | @Schema(description = "å·¥èµ") |
| | | private BigDecimal wages; |
| | | |
| | | @Schema(description = "åå·¥èµ") |
| | | private BigDecimal originalWages; |
| | | |
| | | @Schema(description = "补修çå·¥æ¶") |
| | | private BigDecimal repairWorkHour; |
| | | |
| | | @Schema(description = "å·¥èµä¿®æ£éé¢") |
| | | private BigDecimal adjustAmount; |
| | | |
| | |
| | | exportDto.setWorkHour(item.getWorkHour()); |
| | | exportDto.setQuantity(item.getQuantity()); |
| | | exportDto.setWorkHours(item.getWorkHours()); |
| | | exportDto.setOriginalWages(item.getOriginalWages()); |
| | | exportDto.setAdjustAmount(item.getAdjustAmount()); |
| | | exportDto.setWages(item.getWages()); |
| | | return exportDto; |
| | | }) |
| | |
| | | @Schema(description = "å·¥æ¶") |
| | | private BigDecimal workHour; |
| | | |
| | | @Schema(description = "补修çå·¥æ¶") |
| | | @TableField("repair_work_hour") |
| | | private BigDecimal repairWorkHour; |
| | | |
| | | } |
| | |
| | | import java.time.LocalDate; |
| | | import java.time.LocalDateTime; |
| | | import java.time.format.DateTimeParseException; |
| | | import java.util.Arrays; |
| | | import java.util.List; |
| | | |
| | | @Service |
| | |
| | | if (queryDto.getAuditStatus() == null) { |
| | | queryDto.setAuditStatus(1); |
| | | } |
| | | if (queryDto.getReportType() == null) { |
| | | queryDto.setReportType(0); |
| | | } |
| | | return productionProductMainMapper.listProductionDetails(queryDto, page); |
| | | } |
| | | |
| | |
| | | ProductionAccountDto queryDto = normalizeDateQuery(dto); |
| | | LambdaQueryWrapper<ProductionProductMain> queryWrapper = Wrappers.<ProductionProductMain>lambdaQuery() |
| | | .eq(ProductionProductMain::getAuditStatus, 1) |
| | | .eq(ProductionProductMain::getReportType, 0); |
| | | .in(ProductionProductMain::getReportType, Arrays.asList(0, 1)); |
| | | if (queryDto.getSchedulingUserId() != null) { |
| | | queryWrapper.eq(ProductionProductMain::getUserId, queryDto.getSchedulingUserId()); |
| | | } |
| | |
| | | productionAccountDelete(productionProductMainId); |
| | | return Boolean.FALSE; |
| | | } |
| | | if (productionProductMain.getReportType() == null || productionProductMain.getReportType() != 0) { |
| | | if (productionProductMain.getReportType() == null |
| | | || (!Integer.valueOf(0).equals(productionProductMain.getReportType()) |
| | | && !Integer.valueOf(1).equals(productionProductMain.getReportType()))) { |
| | | productionAccountDelete(productionProductMainId); |
| | | return Boolean.FALSE; |
| | | } |
| | |
| | | && productionProductMain.getAuditStatus() != null |
| | | && productionProductMain.getAuditStatus() == 1 |
| | | && productionProductMain.getReportType() != null |
| | | && productionProductMain.getReportType() == 0; |
| | | && (productionProductMain.getReportType() == 0 || productionProductMain.getReportType() == 1); |
| | | } |
| | | |
| | | private boolean isExcludedFromWage(ProductionProductMain productionProductMain) { |
| | | return productionProductMain != null |
| | | && productionProductMain.getReportType() != null |
| | | && productionProductMain.getReportType() != 0; |
| | | && productionProductMain.getReportType() != 0 |
| | | && productionProductMain.getReportType() != 1; |
| | | } |
| | | |
| | | @Override |
| | |
| | | return R.ok(qualityReportService.getTopParameters(modelType)); |
| | | } |
| | | |
| | | /** |
| | | * è·åæäººå/çç»ç»è®¡è´¨éæ°æ® |
| | | */ |
| | | @Operation(summary = "è·åæäººå/çç»ç»è®¡è´¨éæ°æ®") |
| | | @GetMapping("/getPersonGroupRateStatistics") |
| | | @Log(title = "è·åæäººå/çç»ç»è®¡è´¨éæ°æ®", businessType = BusinessType.OTHER) |
| | | public R<?> getPersonGroupRateStatistics() { |
| | | return R.ok(qualityReportService.getPersonGroupRateStatistics()); |
| | | } |
| | | |
| | | } |
| | |
| | | @Log(title = "æ°å¢ä¸åæ ¼ç®¡ç", businessType = BusinessType.INSERT) |
| | | public R<?> add(@RequestBody QualityUnqualified qualityUnqualified) { |
| | | qualityUnqualified.setInspectState(0); |
| | | if (qualityUnqualified.getDealType() != null) { |
| | | qualityUnqualified.setDealResult(resolveDealResult(qualityUnqualified.getDealType())); |
| | | } |
| | | normalizeDealDecision(qualityUnqualified); |
| | | applyRegenerateNewOrderDefault(qualityUnqualified); |
| | | normalizeRepairWorkHour(qualityUnqualified); |
| | | return R.ok(qualityUnqualifiedService.save(qualityUnqualified)); |
| | | } |
| | |
| | | @Operation(summary = "ä¸åæ ¼ç®¡çä¿®æ¹") |
| | | @Log(title = "ä¸åæ ¼ç®¡çä¿®æ¹", businessType = BusinessType.UPDATE) |
| | | public R<?> update(@RequestBody QualityUnqualified qualityUnqualified) { |
| | | if (qualityUnqualified.getDealType() != null) { |
| | | qualityUnqualified.setDealResult(resolveDealResult(qualityUnqualified.getDealType())); |
| | | } |
| | | normalizeDealDecision(qualityUnqualified); |
| | | applyRegenerateNewOrderDefault(qualityUnqualified); |
| | | normalizeRepairWorkHour(qualityUnqualified); |
| | | return R.ok(qualityUnqualifiedService.updateById(qualityUnqualified)); |
| | | } |
| | |
| | | @Operation(summary = "ä¸åæ ¼ç®¡çå¤ç") |
| | | @Log(title = "ä¸åæ ¼ç®¡çå¤ç", businessType = BusinessType.OTHER) |
| | | public R<?> deal(@RequestBody QualityUnqualified qualityUnqualified) { |
| | | if (qualityUnqualified.getDealType() != null) { |
| | | qualityUnqualified.setDealResult(resolveDealResult(qualityUnqualified.getDealType())); |
| | | } |
| | | normalizeDealDecision(qualityUnqualified); |
| | | applyRegenerateNewOrderDefault(qualityUnqualified); |
| | | normalizeRepairWorkHour(qualityUnqualified); |
| | | return R.ok(qualityUnqualifiedService.deal(qualityUnqualified)); |
| | | } |
| | | |
| | | private String resolveDealResult(Integer dealType) { |
| | | if (dealType == null) { |
| | | return null; |
| | | private void normalizeDealDecision(QualityUnqualified qualityUnqualified) { |
| | | if (qualityUnqualified == null) { |
| | | return; |
| | | } |
| | | return switch (dealType) { |
| | | case 0 -> "轻微è¿å·¥"; |
| | | case 1 -> "严éè¿å·¥"; |
| | | case 2 -> "æ¥åº"; |
| | | default -> null; |
| | | }; |
| | | String dealResult = qualityUnqualified.getDealResult(); |
| | | Integer dealType = qualityUnqualified.getDealType(); |
| | | if ("æ¥åº".equals(dealResult)) { |
| | | qualityUnqualified.setDealType(2); |
| | | return; |
| | | } |
| | | if ("æ¥å·¥".equals(dealResult)) { |
| | | if (dealType == null) { |
| | | throw new ServiceException("æ¥å·¥æ¶å¿
须鿩ä¸åæ ¼ç±»å"); |
| | | } |
| | | if (dealType == 2) { |
| | | qualityUnqualified.setDealResult("æ¥åº"); |
| | | } |
| | | return; |
| | | } |
| | | if (dealType == null) { |
| | | return; |
| | | } |
| | | if (dealType == 2) { |
| | | qualityUnqualified.setDealResult("æ¥åº"); |
| | | } else if (dealType == 0 || dealType == 1) { |
| | | qualityUnqualified.setDealResult("æ¥å·¥"); |
| | | } |
| | | } |
| | | |
| | | private void applyRegenerateNewOrderDefault(QualityUnqualified qualityUnqualified) { |
| | | if (qualityUnqualified == null || qualityUnqualified.getDealType() == null) { |
| | | return; |
| | | } |
| | | if (qualityUnqualified.getDealType() == 0) { |
| | | qualityUnqualified.setRegenerateNewOrder(0); |
| | | } else if (qualityUnqualified.getDealType() == 1 || qualityUnqualified.getDealType() == 2) { |
| | | qualityUnqualified.setRegenerateNewOrder(1); |
| | | } |
| | | } |
| | | |
| | | private void normalizeRepairWorkHour(QualityUnqualified qualityUnqualified) { |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.quality.dto; |
| | | |
| | | import io.swagger.v3.oas.annotations.media.Schema; |
| | | import lombok.Data; |
| | | |
| | | import java.io.Serializable; |
| | | import java.math.BigDecimal; |
| | | |
| | | @Data |
| | | @Schema(name = "QualityPersonGroupRateDto", description = "æäººå/çç»ç»è®¡è´¨éæ¯çDTO") |
| | | public class QualityPersonGroupRateDto implements Serializable { |
| | | |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | @Schema(description = "维度ID") |
| | | private Long dimensionId; |
| | | |
| | | @Schema(description = "维度åç§°") |
| | | private String dimensionName; |
| | | |
| | | @Schema(description = "æ»æ°é") |
| | | private BigDecimal totalCount; |
| | | |
| | | @Schema(description = "åæ ¼æ°é") |
| | | private BigDecimal qualifiedCount; |
| | | |
| | | @Schema(description = "ä¸åæ ¼æ°é") |
| | | private BigDecimal unqualifiedCount; |
| | | |
| | | @Schema(description = "è¿å·¥æ°é") |
| | | private BigDecimal reworkCount; |
| | | |
| | | @Schema(description = "æ¥åºæ°é") |
| | | private BigDecimal scrapCount; |
| | | |
| | | @Schema(description = "åæ ¼ç") |
| | | private BigDecimal passRate; |
| | | |
| | | @Schema(description = "è¿å·¥ç") |
| | | private BigDecimal reworkRate; |
| | | |
| | | @Schema(description = "æ¥åºç") |
| | | private BigDecimal scrapRate; |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.quality.dto; |
| | | |
| | | import io.swagger.v3.oas.annotations.media.Schema; |
| | | import lombok.Data; |
| | | |
| | | import java.io.Serializable; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | |
| | | @Data |
| | | @Schema(name = "QualityPersonGroupRateWrapperDto", description = "æäººå/çç»ç»è®¡è´¨éæ¯çå
è£
DTO") |
| | | public class QualityPersonGroupRateWrapperDto implements Serializable { |
| | | |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | @Schema(description = "æäººåç»è®¡") |
| | | private List<QualityPersonGroupRateDto> personList = new ArrayList<>(); |
| | | |
| | | @Schema(description = "æçç»ç»è®¡") |
| | | private List<QualityPersonGroupRateDto> groupList = new ArrayList<>(); |
| | | } |
| | |
| | | * è·åçç¹æ£æµææ Top 4 + å
¶ä» |
| | | */ |
| | | List<QualityParameterStatDto> getTopParameters(@Param("modelType") Integer modelType); |
| | | |
| | | List<QualityPersonGroupRateDto> getPersonRateStatistics(); |
| | | |
| | | List<QualityPersonGroupRateDto> getGroupRateStatistics(); |
| | | } |
| | |
| | | import com.ruoyi.quality.dto.QualityMonthlyDetailDto; |
| | | import com.ruoyi.quality.dto.QualityParameterStatDto; |
| | | import com.ruoyi.quality.dto.QualityMonthlyPassRateWrapperDto; |
| | | import com.ruoyi.quality.dto.QualityPersonGroupRateWrapperDto; |
| | | import com.ruoyi.quality.dto.QualityTopParameterDto; |
| | | |
| | | import java.util.List; |
| | |
| | | List<QualityMonthlyDetailDto> getMonthlyCompletionDetails(String year); |
| | | |
| | | QualityTopParameterDto getTopParameters(Integer inspectType); |
| | | |
| | | QualityPersonGroupRateWrapperDto getPersonGroupRateStatistics(); |
| | | } |
| | |
| | | import com.ruoyi.framework.web.domain.R; |
| | | import com.ruoyi.procurementrecord.service.ProcurementRecordService; |
| | | import com.ruoyi.procurementrecord.utils.StockUtils; |
| | | import com.ruoyi.production.mapper.ProductionProductMainMapper; |
| | | import com.ruoyi.production.pojo.ProductionProductMain; |
| | | import com.ruoyi.quality.dto.QualityInspectDto; |
| | | import com.ruoyi.quality.mapper.QualityInspectMapper; |
| | | import com.ruoyi.quality.mapper.QualityTestStandardMapper; |
| | |
| | | private SalesLedgerProductMapper salesLedgerProductMapper; |
| | | |
| | | private ProcurementRecordService procurementRecordService; |
| | | |
| | | private ProductionProductMainMapper productionProductMainMapper; |
| | | |
| | | @Override |
| | | public int add(QualityInspectDto qualityInspectDto) { |
| | |
| | | qualityUnqualified.setInspectState(0);//å¾
å¤ç |
| | | qualityUnqualified.setQuantity(qualityInspect.getUnqualifiedQuantity()); |
| | | qualityUnqualified.setProductModelId(qualityInspect.getProductModelId()); |
| | | applyDealTypeByReportType(qualityInspect, qualityUnqualified); |
| | | List<QualityInspectParam> inspectParams = qualityInspectParamService.list(Wrappers.<QualityInspectParam>lambdaQuery().eq(QualityInspectParam::getInspectId, inspect.getId())); |
| | | String text = inspectParams.stream().map(QualityInspectParam::getParameterItem).collect(Collectors.joining(",")); |
| | | qualityUnqualified.setDefectivePhenomena(text + "è¿äºææ ä¸åå¨ä¸åæ ¼");//ä¸åæ ¼ç°è±¡ |
| | |
| | | return qualityInspectMapper.updateById(qualityInspect); |
| | | } |
| | | |
| | | private void applyDealTypeByReportType(QualityInspect qualityInspect, QualityUnqualified qualityUnqualified) { |
| | | if (qualityInspect == null || qualityUnqualified == null || qualityInspect.getProductMainId() == null) { |
| | | return; |
| | | } |
| | | ProductionProductMain productMain = productionProductMainMapper.selectById(qualityInspect.getProductMainId()); |
| | | if (productMain == null || productMain.getReportType() == null) { |
| | | return; |
| | | } |
| | | switch (productMain.getReportType()) { |
| | | case 1: |
| | | qualityUnqualified.setDealType(0); |
| | | qualityUnqualified.setDealResult("æ¥å·¥"); |
| | | break; |
| | | case 2: |
| | | qualityUnqualified.setDealType(1); |
| | | qualityUnqualified.setDealResult("æ¥å·¥"); |
| | | break; |
| | | case 3: |
| | | qualityUnqualified.setDealType(2); |
| | | qualityUnqualified.setDealResult("æ¥åº"); |
| | | break; |
| | | default: |
| | | break; |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public R autoSubmit(Long id) { |
| | | if (id == null) { |
| | |
| | | |
| | | return result; |
| | | } |
| | | |
| | | @Override |
| | | public QualityPersonGroupRateWrapperDto getPersonGroupRateStatistics() { |
| | | QualityPersonGroupRateWrapperDto result = new QualityPersonGroupRateWrapperDto(); |
| | | result.setPersonList(qualityInspectMapper.getPersonRateStatistics()); |
| | | result.setGroupList(qualityInspectMapper.getGroupRateStatistics()); |
| | | return result; |
| | | } |
| | | } |
| | |
| | | import com.ruoyi.common.utils.poi.ExcelUtil; |
| | | import com.ruoyi.procurementrecord.utils.StockUtils; |
| | | import com.ruoyi.production.mapper.ProductionOperationTaskMapper; |
| | | import com.ruoyi.production.mapper.ProductionOrderMapper; |
| | | import com.ruoyi.production.mapper.ProductionOrderRoutingMapper; |
| | | import com.ruoyi.production.mapper.ProductionOrderRoutingOperationMapper; |
| | | import com.ruoyi.production.mapper.ProductionProductMainMapper; |
| | | import com.ruoyi.production.service.ProductionAccountService; |
| | | import com.ruoyi.production.pojo.ProductionOperationTask; |
| | | import com.ruoyi.production.pojo.ProductionOrder; |
| | | import com.ruoyi.production.pojo.ProductionOrderRouting; |
| | | import com.ruoyi.production.pojo.ProductionOrderRoutingOperation; |
| | | import com.ruoyi.production.pojo.ProductionProductMain; |
| | | import com.ruoyi.quality.mapper.QualityUnqualifiedMapper; |
| | | import com.ruoyi.quality.pojo.QualityInspect; |
| | |
| | | import com.ruoyi.stock.service.StockUninventoryService; |
| | | import lombok.AllArgsConstructor; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import jakarta.servlet.http.HttpServletResponse; |
| | | import java.math.BigDecimal; |
| | | import java.time.LocalDate; |
| | | import java.time.format.DateTimeFormatter; |
| | | import java.util.Arrays; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | @AllArgsConstructor |
| | | @Service |
| | |
| | | private final QualityUnqualifiedMapper qualityUnqualifiedMapper; |
| | | private final IQualityInspectService qualityInspectService; |
| | | private final ProductionProductMainMapper productionProductMainMapper; |
| | | private final ProductionOrderMapper productionOrderMapper; |
| | | private final ProductionOrderRoutingMapper productionOrderRoutingMapper; |
| | | private final ProductionOrderRoutingOperationMapper productionOrderRoutingOperationMapper; |
| | | private final ProductionOperationTaskMapper productionOperationTaskMapper; |
| | | private final StockUninventoryService stockUninventoryService; |
| | | private final StockInRecordService stockInRecordService; |
| | | private final ProductionAccountService productionAccountService; |
| | | |
| | | @Override |
| | | public IPage<QualityUnqualified> qualityUnqualifiedListPage(Page page, QualityUnqualified qualityUnqualified) { |
| | |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public int deal(QualityUnqualified qualityUnqualified) { |
| | | QualityUnqualified unqualified = qualityUnqualifiedMapper.selectById(qualityUnqualified.getId()); |
| | | QualityInspect qualityInspect = qualityInspectService.getById(unqualified.getInspectId()); |
| | | String batchNo = qualityInspect == null ? null |
| | | : resolveProductionBatchNo(qualityInspect.getProductMainId(), qualityInspect.getId(), qualityInspect.getProductModelId()); |
| | | if (qualityUnqualified.getDealType() != null) { |
| | | switch (qualityUnqualified.getDealType()) { |
| | | case 0: |
| | | qualityUnqualified.setDealResult("轻微è¿å·¥"); |
| | | break; |
| | | case 1: |
| | | qualityUnqualified.setDealResult("严éè¿å·¥"); |
| | | break; |
| | | case 2: |
| | | qualityUnqualified.setDealResult("æ¥åº"); |
| | | break; |
| | | default: |
| | | break; |
| | | } |
| | | } |
| | | if (ObjectUtils.isNotNull(qualityInspect) && qualityInspect.getInspectType() != 0) { |
| | | ProductionProductMain sourceMain = null; |
| | | if (ObjectUtils.isNotNull(qualityInspect.getProductMainId())) { |
| | | sourceMain = productionProductMainMapper.selectById(qualityInspect.getProductMainId()); |
| | | } |
| | | switch (qualityUnqualified.getDealResult()) { |
| | | case "严éè¿å·¥": |
| | | case "轻微è¿å·¥": |
| | | if (ObjectUtils.isNotNull(qualityInspect.getProductMainId())) { |
| | | ProductionProductMain sourceMain = productionProductMainMapper.selectById(qualityInspect.getProductMainId()); |
| | | if (sourceMain == null || sourceMain.getProductionOperationTaskId() == null) { |
| | | throw new ServiceException("å岿¥å·¥æªç»å®ç产工åï¼æ æ³ææ°æ¨¡åè¿å·¥"); |
| | | } |
| | | createReworkProductionByNewModel(sourceMain, unqualified.getQuantity()); |
| | | } |
| | | case "æ¥å·¥": |
| | | handleProductionReportResult(qualityUnqualified, unqualified, sourceMain); |
| | | break; |
| | | case "æ¥åº": |
| | | stockUtils.addUnStockWithBatchNo(qualityInspect.getProductModelId(), unqualified.getQuantity(), |
| | | StockInQualifiedRecordTypeEnum.DEFECTIVE_SCRAP.getCode(), unqualified.getId(), batchNo); |
| | | qualityUnqualified.setRegenerateNewOrder(1); |
| | | handleProductionScrapResult(qualityInspect, qualityUnqualified, unqualified, sourceMain, batchNo); |
| | | break; |
| | | case "è®©æ¥æ¾è¡": |
| | | stockUtils.addStockWithBatchNo(qualityInspect.getProductModelId(), unqualified.getQuantity(), |
| | |
| | | return qualityUnqualifiedMapper.getUnqualified(id); |
| | | } |
| | | |
| | | private void handleProductionReportResult(QualityUnqualified qualityUnqualified, |
| | | QualityUnqualified sourceUnqualified, |
| | | ProductionProductMain sourceMain) { |
| | | Integer dealType = qualityUnqualified.getDealType(); |
| | | if (dealType == null) { |
| | | throw new ServiceException("æ¥å·¥æ¶å¿
须鿩ä¸åæ ¼ç±»å"); |
| | | } |
| | | if (sourceMain == null || sourceMain.getProductionOperationTaskId() == null) { |
| | | throw new ServiceException("å岿¥å·¥æªç»å®ç产工åï¼æ æ³æ§è¡æ¥å·¥å¤ç"); |
| | | } |
| | | if (Integer.valueOf(0).equals(dealType)) { |
| | | applyLightRework(sourceMain, qualityUnqualified); |
| | | return; |
| | | } |
| | | if (Integer.valueOf(1).equals(dealType)) { |
| | | markSourceMainAsUnpaid(sourceMain, 2); |
| | | createReworkProductionByNewModel(sourceMain, sourceUnqualified.getQuantity()); |
| | | qualityUnqualified.setRegenerateNewOrder(1); |
| | | productionAccountService.rebuildByProductionProductMainId(sourceMain.getId()); |
| | | return; |
| | | } |
| | | throw new ServiceException("æ¥å·¥å¤çä»
æ¯æè½»å¾®è¿å·¥æä¸¥éè¿å·¥"); |
| | | } |
| | | |
| | | private void handleProductionScrapResult(QualityInspect qualityInspect, |
| | | QualityUnqualified qualityUnqualified, |
| | | QualityUnqualified sourceUnqualified, |
| | | ProductionProductMain sourceMain, |
| | | String batchNo) { |
| | | if (sourceMain == null || sourceMain.getProductionOperationTaskId() == null) { |
| | | throw new ServiceException("å岿¥å·¥æªç»å®ç产工åï¼æ æ³æ§è¡æ¥åºå¤ç"); |
| | | } |
| | | markSourceMainAsUnpaid(sourceMain, 3); |
| | | createReworkProductionByNewModel(sourceMain, sourceUnqualified.getQuantity()); |
| | | qualityUnqualified.setRegenerateNewOrder(1); |
| | | productionAccountService.rebuildByProductionProductMainId(sourceMain.getId()); |
| | | // åææ¥åºåºåå¤çé»è¾å
ææ°è§å注éï¼ä¸åç´æ¥æä¸åæ ¼åæ§è¡æ¥åºåºåºã |
| | | // stockUtils.addUnStockWithBatchNo(qualityInspect.getProductModelId(), sourceUnqualified.getQuantity(), |
| | | // StockInQualifiedRecordTypeEnum.DEFECTIVE_SCRAP.getCode(), sourceUnqualified.getId(), batchNo); |
| | | } |
| | | |
| | | private void applyLightRework(ProductionProductMain sourceMain, QualityUnqualified qualityUnqualified) { |
| | | if (qualityUnqualified.getRepairWorkHour() == null |
| | | || qualityUnqualified.getRepairWorkHour().compareTo(BigDecimal.ZERO) <= 0) { |
| | | throw new ServiceException("轻微è¿å·¥å¿
须填å大äº0çä¿®çå·¥æ¶"); |
| | | } |
| | | ProductionProductMain update = new ProductionProductMain(); |
| | | update.setId(sourceMain.getId()); |
| | | update.setReportType(1); |
| | | update.setRepairWorkHour(defaultDecimal(sourceMain.getRepairWorkHour()).add(defaultDecimal(qualityUnqualified.getRepairWorkHour()))); |
| | | productionProductMainMapper.updateById(update); |
| | | qualityUnqualified.setRegenerateNewOrder(0); |
| | | productionAccountService.rebuildByProductionProductMainId(sourceMain.getId()); |
| | | } |
| | | |
| | | private void markSourceMainAsUnpaid(ProductionProductMain sourceMain, int reportType) { |
| | | ProductionProductMain update = new ProductionProductMain(); |
| | | update.setId(sourceMain.getId()); |
| | | update.setReportType(reportType); |
| | | productionProductMainMapper.updateById(update); |
| | | } |
| | | |
| | | private void createReworkProductionByNewModel(ProductionProductMain sourceMain, BigDecimal quantity) { |
| | | ProductionOperationTask sourceTask = productionOperationTaskMapper.selectById(sourceMain.getProductionOperationTaskId()); |
| | | if (sourceTask == null) { |
| | | throw new ServiceException("å
³èçç产工åä¸åå¨"); |
| | | } |
| | | ProductionOrder sourceOrder = productionOrderMapper.selectById(sourceTask.getProductionOrderId()); |
| | | if (sourceOrder == null) { |
| | | throw new ServiceException("å
³èçç产订åä¸åå¨"); |
| | | } |
| | | |
| | | ProductionOrder newOrder = new ProductionOrder(); |
| | | BeanUtils.copyProperties(sourceOrder, newOrder); |
| | | newOrder.setId(null); |
| | | newOrder.setNpsNo(generateNextProductionOrderNo("FG")); |
| | | newOrder.setQuantity(defaultDecimal(quantity)); |
| | | newOrder.setCompleteQuantity(BigDecimal.ZERO); |
| | | newOrder.setStartTime(null); |
| | | newOrder.setEndTime(null); |
| | | newOrder.setCreateTime(null); |
| | | newOrder.setUpdateTime(null); |
| | | productionOrderMapper.insert(newOrder); |
| | | |
| | | Map<Long, Long> routingIdMap = new HashMap<>(); |
| | | List<ProductionOrderRouting> sourceRoutings = productionOrderRoutingMapper.selectList( |
| | | Wrappers.<ProductionOrderRouting>lambdaQuery() |
| | | .eq(ProductionOrderRouting::getProductionOrderId, sourceOrder.getId()) |
| | | .orderByAsc(ProductionOrderRouting::getId)); |
| | | for (ProductionOrderRouting sourceRouting : sourceRoutings) { |
| | | ProductionOrderRouting newRouting = new ProductionOrderRouting(); |
| | | BeanUtils.copyProperties(sourceRouting, newRouting); |
| | | newRouting.setId(null); |
| | | newRouting.setProductionOrderId(newOrder.getId()); |
| | | newRouting.setCreateTime(null); |
| | | newRouting.setUpdateTime(null); |
| | | productionOrderRoutingMapper.insert(newRouting); |
| | | routingIdMap.put(sourceRouting.getId(), newRouting.getId()); |
| | | } |
| | | |
| | | List<ProductionOrderRoutingOperation> sourceOperations = productionOrderRoutingOperationMapper.selectList( |
| | | Wrappers.<ProductionOrderRoutingOperation>lambdaQuery() |
| | | .eq(ProductionOrderRoutingOperation::getProductionOrderId, sourceOrder.getId()) |
| | | .orderByAsc(ProductionOrderRoutingOperation::getDragSort) |
| | | .orderByAsc(ProductionOrderRoutingOperation::getId)); |
| | | for (ProductionOrderRoutingOperation sourceOperation : sourceOperations) { |
| | | ProductionOrderRoutingOperation newOperation = new ProductionOrderRoutingOperation(); |
| | | BeanUtils.copyProperties(sourceOperation, newOperation); |
| | | newOperation.setId(null); |
| | | newOperation.setProductionOrderId(newOrder.getId()); |
| | | newOperation.setOrderRoutingId(routingIdMap.get(sourceOperation.getOrderRoutingId())); |
| | | newOperation.setCreateTime(null); |
| | | newOperation.setUpdateTime(null); |
| | | productionOrderRoutingOperationMapper.insert(newOperation); |
| | | |
| | | ProductionOperationTask newTask = new ProductionOperationTask(); |
| | | newTask.setProductionOrderRoutingOperationId(newOperation.getId()); |
| | | newTask.setProductionOrderId(newOrder.getId()); |
| | | newTask.setPlanQuantity(newOrder.getQuantity()); |
| | | newTask.setCompleteQuantity(BigDecimal.ZERO); |
| | | newTask.setWorkOrderNo(generateNextTaskNo("FG")); |
| | | newTask.setStatus(1); |
| | | productionOperationTaskMapper.insert(newTask); |
| | | } |
| | | } |
| | | |
| | | private String generateNextProductionOrderNo(String prefix) { |
| | | String datePrefix = LocalDate.now().format(DateTimeFormatter.ofPattern("yyyyMMdd")); |
| | | String orderPrefix = prefix + datePrefix; |
| | | ProductionOrder latestOrder = productionOrderMapper.selectOne( |
| | | Wrappers.<ProductionOrder>lambdaQuery() |
| | | .likeRight(ProductionOrder::getNpsNo, orderPrefix) |
| | | .orderByDesc(ProductionOrder::getNpsNo) |
| | | .last("limit 1")); |
| | | int sequence = 1; |
| | | if (latestOrder != null && latestOrder.getNpsNo() != null && latestOrder.getNpsNo().startsWith(orderPrefix)) { |
| | | try { |
| | | sequence = Integer.parseInt(latestOrder.getNpsNo().substring(orderPrefix.length())) + 1; |
| | | } catch (NumberFormatException ignored) { |
| | | sequence = 1; |
| | | } |
| | | } |
| | | return orderPrefix + String.format("%04d", sequence); |
| | | ProductionOperationTask newTask = new ProductionOperationTask(); |
| | | BeanUtils.copyProperties(sourceTask, newTask); |
| | | newTask.setId(null); |
| | | newTask.setWorkOrderNo(generateNextTaskNo("FG")); |
| | | newTask.setPlanQuantity(defaultDecimal(quantity)); |
| | | newTask.setCompleteQuantity(BigDecimal.ZERO); |
| | | newTask.setPlanStartTime(null); |
| | | newTask.setPlanEndTime(null); |
| | | newTask.setActualStartTime(null); |
| | | newTask.setActualEndTime(null); |
| | | newTask.setStatus(1); |
| | | newTask.setCreateTime(null); |
| | | newTask.setUpdateTime(null); |
| | | productionOperationTaskMapper.insert(newTask); |
| | | } |
| | | |
| | | private String generateNextTaskNo(String prefix) { |
| | |
| | | cast(sum( |
| | | case |
| | | when pa.adjust_amount is not null then ifnull(pa.adjust_amount, 0) |
| | | when poro.type = 0 then ifnull(pa.work_hours, 0) * ifnull(ppm.work_hour, 0) |
| | | when poro.type = 0 then ifnull(pa.work_hours, 0) * (ifnull(ppm.work_hour, 0) + ifnull(ppm.repair_work_hour, 0)) |
| | | else ifnull(pa.work_hours, 0) * ifnull(pa.finished_num, 0) * |
| | | case |
| | | when substring_index(pm.model, '*', -1) regexp '^[0-9]+(\\.[0-9]+)?$' |
| | |
| | | ) ppo on ppo.production_product_main_id = ppm.id |
| | | <where> |
| | | and ppm.audit_status = 1 |
| | | and ppm.report_type = 0 |
| | | and ppm.report_type in (0, 1) |
| | | <if test="c != null"> |
| | | <if test="c.productCategory != null and c.productCategory != ''"> |
| | | and p_parent.product_name like concat('%', #{c.productCategory}, '%') |
| | |
| | | </select> |
| | | |
| | | <select id="selectUserAccount" resultType="com.ruoyi.production.bean.dto.UserAccountDto"> |
| | | select ifnull(sum(finished_num), 0) as accountBalance, |
| | | ifnull(sum(work_hours), 0) as account |
| | | select cast(ifnull(sum( |
| | | case |
| | | when pa.adjust_amount is not null then 0 |
| | | when poro.type = 0 then 0 |
| | | else ifnull(pa.work_hours, 0) * ifnull(pa.finished_num, 0) * |
| | | case |
| | | when substring_index(pm.model, '*', -1) regexp '^[0-9]+(\\.[0-9]+)?$' |
| | | then cast(substring_index(pm.model, '*', -1) as decimal(18,4)) |
| | | else 1 |
| | | end |
| | | end |
| | | ), 0) as decimal(18,2)) as accountBalance, |
| | | cast(ifnull(sum( |
| | | case |
| | | when pa.adjust_amount is not null then ifnull(pa.adjust_amount, 0) |
| | | when poro.type = 0 then ifnull(pa.work_hours, 0) * (ifnull(ppm.work_hour, 0) + ifnull(ppm.repair_work_hour, 0)) |
| | | else 0 |
| | | end |
| | | ), 0) as decimal(18,2)) as account |
| | | from production_account pa |
| | | inner join production_product_main ppm on ppm.id = pa.production_product_main_id |
| | | left join production_product_main ppm on ppm.id = pa.production_product_main_id |
| | | left join production_operation_task pot on ppm.production_operation_task_id = pot.id |
| | | left join production_order po on pot.production_order_id = po.id |
| | | left join production_order_routing_operation poro on pot.production_order_routing_operation_id = poro.id |
| | | left join product_model pm on pm.id = ifnull(poro.product_model_id, po.product_model_id) |
| | | where pa.scheduling_user_id = #{userId} |
| | | and date_format(pa.scheduling_date, '%Y-%m') = #{date} |
| | | and ppm.audit_status = 1 |
| | | and ppm.report_type = 0 |
| | | and ( |
| | | pa.production_product_main_id is null |
| | | or ( |
| | | ppm.audit_status = 1 |
| | | and ppm.report_type in (0, 1) |
| | | ) |
| | | ) |
| | | </select> |
| | | |
| | | <select id="selectDailyWagesStats" resultType="java.util.Map"> |
| | |
| | | where pa.scheduling_date >= #{startDate} |
| | | and pa.scheduling_date <= #{endDate} |
| | | and ppm.audit_status = 1 |
| | | and ppm.report_type = 0 |
| | | and ppm.report_type in (0, 1) |
| | | group by date_format(scheduling_date, '%m-%d') |
| | | order by date_format(scheduling_date, '%m-%d') |
| | | </select> |
| | |
| | | date(ppm.create_time) as schedulingDate, |
| | | su.nick_name as schedulingUserName, |
| | | po_sales.customerName, |
| | | poro.operation_name as process |
| | | poro.operation_name as process, |
| | | ppm.repair_work_hour as repairWorkHour |
| | | from production_product_main ppm |
| | | left join production_operation_task pot on ppm.production_operation_task_id = pot.id |
| | | left join production_order po on pot.production_order_id = po.id |
| | |
| | | date(pa.scheduling_date) as schedulingDate, |
| | | pa.scheduling_user_id as schedulingUserId, |
| | | pa.scheduling_user_name as schedulingUserName, |
| | | ppm.repair_work_hour as repairWorkHour, |
| | | cast(ifnull(ppm.work_hour, 0) as decimal(18,4)) as workHour, |
| | | cast(ifnull(pa.work_hours, 0) as decimal(18,4)) as workHours, |
| | | cast(ifnull(pa.adjust_amount, 0) as decimal(18,4)) as adjustAmount, |
| | | pa.adjust_remark as adjustRemark, |
| | | cast( |
| | | case |
| | | when poro.type = 0 then ifnull(pa.work_hours, 0) * (ifnull(ppm.work_hour, 0) + ifnull(ppm.repair_work_hour, 0)) |
| | | else ifnull(pa.work_hours, 0) * ifnull(pa.finished_num, 0) * |
| | | case |
| | | when substring_index(pm.model, '*', -1) regexp '^[0-9]+(\\.[0-9]+)?$' |
| | | then cast(substring_index(pm.model, '*', -1) as decimal(18,4)) |
| | | else 1 |
| | | end |
| | | end |
| | | as decimal(18,4) |
| | | ) as originalWages, |
| | | cast( |
| | | case |
| | | when pa.adjust_amount is not null then ifnull(pa.adjust_amount, 0) |
| | | when poro.type = 0 then ifnull(pa.work_hours, 0) * ifnull(ppm.work_hour, 0) |
| | | when poro.type = 0 then ifnull(pa.work_hours, 0) * (ifnull(ppm.work_hour, 0) + ifnull(ppm.repair_work_hour, 0)) |
| | | else ifnull(pa.work_hours, 0) * ifnull(pa.finished_num, 0) * |
| | | case |
| | | when substring_index(pm.model, '*', -1) regexp '^[0-9]+(\\.[0-9]+)?$' |
| | |
| | | <if test="c.reportType != null"> |
| | | and ppm.report_type = #{c.reportType} |
| | | </if> |
| | | <if test="c.reportType == null"> |
| | | and ppm.report_type in (0, 1) |
| | | </if> |
| | | <if test="c.productCategory != null and c.productCategory != ''"> |
| | | and p_parent.product_name like concat('%', #{c.productCategory}, '%') |
| | | </if> |
| | |
| | | |
| | | </select> |
| | | |
| | | <sql id="personGroupRateJoin"> |
| | | FROM quality_inspect qi |
| | | INNER JOIN production_product_main ppm ON qi.product_main_id = ppm.id |
| | | LEFT JOIN ( |
| | | SELECT production_product_main_id, |
| | | CAST(SUM(IFNULL(scrap_qty, 0)) AS DECIMAL(18,4)) AS scrapCount |
| | | FROM production_product_output |
| | | GROUP BY production_product_main_id |
| | | ) ppo ON ppo.production_product_main_id = ppm.id |
| | | LEFT JOIN ( |
| | | SELECT inspect_id, |
| | | CAST(SUM(CASE WHEN deal_type IN (0, 1) THEN IFNULL(quantity, 0) ELSE 0 END) AS DECIMAL(18,4)) AS reworkCount |
| | | FROM quality_unqualified |
| | | WHERE inspect_state = 1 |
| | | GROUP BY inspect_id |
| | | ) qu ON qu.inspect_id = qi.id |
| | | </sql> |
| | | |
| | | <sql id="personGroupRateWhere"> |
| | | WHERE qi.inspect_type IN (1, 2) |
| | | AND qi.inspect_state = 1 |
| | | AND qi.product_main_id IS NOT NULL |
| | | </sql> |
| | | |
| | | <select id="getPersonRateStatistics" resultType="com.ruoyi.quality.dto.QualityPersonGroupRateDto"> |
| | | SELECT ppm.user_id AS dimensionId, |
| | | COALESCE(NULLIF(ppm.user_name, ''), su.nick_name, CONCAT('ç¨æ·', ppm.user_id)) AS dimensionName, |
| | | CAST(SUM(IFNULL(qi.quantity, 0)) AS DECIMAL(18,4)) AS totalCount, |
| | | CAST(SUM(IFNULL(qi.qualified_quantity, 0)) AS DECIMAL(18,4)) AS qualifiedCount, |
| | | CAST(SUM(IFNULL(qi.unqualified_quantity, 0)) AS DECIMAL(18,4)) AS unqualifiedCount, |
| | | CAST(SUM(IFNULL(qu.reworkCount, 0)) AS DECIMAL(18,4)) AS reworkCount, |
| | | CAST(SUM(IFNULL(ppo.scrapCount, 0)) AS DECIMAL(18,4)) AS scrapCount, |
| | | CAST(IF(SUM(IFNULL(qi.quantity, 0)) = 0, 0, |
| | | ROUND(SUM(IFNULL(qi.qualified_quantity, 0)) / SUM(IFNULL(qi.quantity, 0)) * 100, 2)) AS DECIMAL(18,2)) AS passRate, |
| | | CAST(IF(SUM(IFNULL(qi.quantity, 0)) = 0, 0, |
| | | ROUND(SUM(IFNULL(qu.reworkCount, 0)) / SUM(IFNULL(qi.quantity, 0)) * 100, 2)) AS DECIMAL(18,2)) AS reworkRate, |
| | | CAST(IF(SUM(IFNULL(qi.quantity, 0)) + SUM(IFNULL(ppo.scrapCount, 0)) = 0, 0, |
| | | ROUND(SUM(IFNULL(ppo.scrapCount, 0)) / (SUM(IFNULL(qi.quantity, 0)) + SUM(IFNULL(ppo.scrapCount, 0))) * 100, 2)) AS DECIMAL(18,2)) AS scrapRate |
| | | <include refid="personGroupRateJoin"/> |
| | | LEFT JOIN sys_user su ON su.user_id = ppm.user_id |
| | | <include refid="personGroupRateWhere"/> |
| | | GROUP BY ppm.user_id, COALESCE(NULLIF(ppm.user_name, ''), su.nick_name, CONCAT('ç¨æ·', ppm.user_id)) |
| | | ORDER BY passRate DESC, totalCount DESC, dimensionId ASC |
| | | </select> |
| | | |
| | | <select id="getGroupRateStatistics" resultType="com.ruoyi.quality.dto.QualityPersonGroupRateDto"> |
| | | SELECT ppm.user_id AS dimensionId, |
| | | COALESCE(NULLIF(ppm.user_name, ''), su.nick_name, CONCAT('çç»äººå', ppm.user_id)) AS dimensionName, |
| | | CAST(SUM(IFNULL(qi.quantity, 0)) AS DECIMAL(18,4)) AS totalCount, |
| | | CAST(SUM(IFNULL(qi.qualified_quantity, 0)) AS DECIMAL(18,4)) AS qualifiedCount, |
| | | CAST(SUM(IFNULL(qi.unqualified_quantity, 0)) AS DECIMAL(18,4)) AS unqualifiedCount, |
| | | CAST(SUM(IFNULL(qu.reworkCount, 0)) AS DECIMAL(18,4)) AS reworkCount, |
| | | CAST(SUM(IFNULL(ppo.scrapCount, 0)) AS DECIMAL(18,4)) AS scrapCount, |
| | | CAST(IF(SUM(IFNULL(qi.quantity, 0)) = 0, 0, |
| | | ROUND(SUM(IFNULL(qi.qualified_quantity, 0)) / SUM(IFNULL(qi.quantity, 0)) * 100, 2)) AS DECIMAL(18,2)) AS passRate, |
| | | CAST(IF(SUM(IFNULL(qi.quantity, 0)) = 0, 0, |
| | | ROUND(SUM(IFNULL(qu.reworkCount, 0)) / SUM(IFNULL(qi.quantity, 0)) * 100, 2)) AS DECIMAL(18,2)) AS reworkRate, |
| | | CAST(IF(SUM(IFNULL(qi.quantity, 0)) + SUM(IFNULL(ppo.scrapCount, 0)) = 0, 0, |
| | | ROUND(SUM(IFNULL(ppo.scrapCount, 0)) / (SUM(IFNULL(qi.quantity, 0)) + SUM(IFNULL(ppo.scrapCount, 0))) * 100, 2)) AS DECIMAL(18,2)) AS scrapRate |
| | | <include refid="personGroupRateJoin"/> |
| | | LEFT JOIN sys_user su ON su.user_id = ppm.user_id |
| | | <include refid="personGroupRateWhere"/> |
| | | GROUP BY ppm.user_id, COALESCE(NULLIF(ppm.user_name, ''), su.nick_name, CONCAT('çç»äººå', ppm.user_id)) |
| | | ORDER BY passRate DESC, totalCount DESC, dimensionId ASC |
| | | </select> |
| | | |
| | | |
| | | </mapper> |
| | |
| | | qu.unit, |
| | | qu.quantity, |
| | | qu.defective_phenomena, |
| | | qu.deal_type, |
| | | qu.deal_result, |
| | | qu.repair_work_hour, |
| | | qu.regenerate_new_order, |
| | | qu.photo_urls, |
| | | qu.deal_name, |
| | | qu.deal_time, |
| | |
| | | qu.product_name, |
| | | qu.unit, |
| | | qu.quantity, |
| | | qu.defective_phenomena, |
| | | qu.deal_result, |
| | | qu.photo_urls, |
| | | qu.deal_name, |
| | | qu.defective_phenomena, |
| | | qu.deal_type, |
| | | qu.deal_result, |
| | | qu.repair_work_hour, |
| | | qu.regenerate_new_order, |
| | | qu.photo_urls, |
| | | qu.deal_name, |
| | | qu.deal_time, |
| | | CASE |
| | | WHEN qu.model = pm.id THEN pm.model |