| | |
| | | import com.ruoyi.quality.pojo.QualityUnqualified; |
| | | import com.ruoyi.quality.service.IQualityInspectParamService; |
| | | import com.ruoyi.quality.service.IQualityInspectService; |
| | | import com.ruoyi.sales.pojo.SalesLedger; |
| | | import com.ruoyi.sales.mapper.SalesLedgerMapper; |
| | | import com.ruoyi.production.pojo.ProductOrder; |
| | | import com.ruoyi.production.pojo.ProductWorkOrder; |
| | | import com.ruoyi.production.pojo.ProductionProductMain; |
| | | import com.ruoyi.production.mapper.ProductOrderMapper; |
| | | import com.ruoyi.production.mapper.ProductWorkOrderMapper; |
| | | import com.ruoyi.production.mapper.ProductionProductMainMapper; |
| | | import lombok.AllArgsConstructor; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.stereotype.Service; |
| | |
| | | import java.io.InputStream; |
| | | import java.io.OutputStream; |
| | | import java.net.URLEncoder; |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.stream.Collectors; |
| | |
| | | private QualityUnqualifiedMapper qualityUnqualifiedMapper; |
| | | |
| | | private QualityInspectExportHandle qualityInspectExportHandle; |
| | | |
| | | private ProductionProductMainMapper productionProductMainMapper; |
| | | |
| | | private ProductWorkOrderMapper productWorkOrderMapper; |
| | | |
| | | private ProductOrderMapper productOrderMapper; |
| | | |
| | | private SalesLedgerMapper salesLedgerMapper; |
| | | |
| | | @Override |
| | | public int add(QualityInspectDto qualityInspectDto) { |
| | |
| | | qualityUnqualifiedMapper.insert(qualityUnqualified); |
| | | } else { |
| | | //合格直接入库 |
| | | if (inspect.getInspectType() == 2 || inspect.getInspectType() == 0) { |
| | | if (qualityInspect.getInspectType() == 2 || qualityInspect.getInspectType() == 0) { |
| | | stockUtils.addStock(qualityInspect.getProductModelId(), qualityInspect.getQuantity(), StockInQualifiedRecordTypeEnum.QUALITYINSPECT_STOCK_IN.getCode(), qualityInspect.getId(), "-", "-", "-"); |
| | | } |
| | | } |
| | |
| | | detail.setIndex(index); |
| | | index++; |
| | | } |
| | | |
| | | // 格式化检验日期 |
| | | String checkTimeStr; |
| | | if (inspect.getCheckTime() != null) { |
| | | SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); |
| | | checkTimeStr = sdf.format(inspect.getCheckTime()); |
| | | } else { |
| | | checkTimeStr = ""; |
| | | } |
| | | |
| | | InputStream inputStream = this.getClass().getResourceAsStream("/static/report-template.docx"); |
| | | Configure configure = Configure.builder() |
| | | .bind("paramList", new HackLoopTableRenderPolicy()) |
| | |
| | | XWPFTemplate template = XWPFTemplate.compile(inputStream, configure).render( |
| | | new HashMap<String, Object>() {{ |
| | | put("inspect", inspect); |
| | | put("customerLabel", inspect.getInspectType() == 0 ? "供应商" : "客户"); |
| | | // 根据检验类型确定客户/供应商 |
| | | String customerValue; |
| | | if (inspect.getInspectType() == 0) { |
| | | // 原材料检验:直接使用供应商 |
| | | customerValue = inspect.getSupplier(); |
| | | } else { |
| | | // 过程检验/出厂检验:通过关联关系查询销售台账的客户 |
| | | customerValue = inspect.getCustomer(); // 默认使用直接存储的客户 |
| | | if (inspect.getProductMainId() != null) { |
| | | // 通过报工ID查询工单 |
| | | ProductionProductMain productMain = productionProductMainMapper.selectById(inspect.getProductMainId()); |
| | | if (productMain != null && productMain.getWorkOrderId() != null) { |
| | | ProductWorkOrder workOrder = productWorkOrderMapper.selectById(productMain.getWorkOrderId()); |
| | | if (workOrder != null && workOrder.getProductOrderId() != null) { |
| | | ProductOrder productOrder = productOrderMapper.selectById(workOrder.getProductOrderId()); |
| | | if (productOrder != null && productOrder.getSalesLedgerId() != null) { |
| | | SalesLedger salesLedger = salesLedgerMapper.selectById(productOrder.getSalesLedgerId()); |
| | | if (salesLedger != null && salesLedger.getCustomerName() != null) { |
| | | customerValue = salesLedger.getCustomerName(); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | put("customer", customerValue); |
| | | put("inspectType", finalInspectType); |
| | | put("paramList", paramList); |
| | | put("checkTime", checkTimeStr); |
| | | }}); |
| | | |
| | | try { |
| | |
| | | qualityInspectExportHandle.exportExcel(response, exportList, exportDTO.getInspectType()); |
| | | } |
| | | |
| | | } |
| | | } |