| | |
| | | import com.deepoove.poi.data.Pictures; |
| | | import com.ruoyi.common.utils.MatrixToImageWriter; |
| | | import com.ruoyi.production.dto.ProductWorkOrderDto; |
| | | import com.ruoyi.production.mapper.ProductProcessRouteItemMapper; |
| | | import com.ruoyi.production.mapper.ProductWorkOrderFileMapper; |
| | | import com.ruoyi.production.mapper.ProductWorkOrderMapper; |
| | | import com.ruoyi.production.mapper.ProductionProductMainMapper; |
| | | import com.ruoyi.production.pojo.ProductProcessRouteItem; |
| | | import com.ruoyi.production.pojo.ProductWorkOrder; |
| | | import com.ruoyi.production.pojo.ProductWorkOrderFile; |
| | | import com.ruoyi.production.pojo.ProductionProductMain; |
| | | import com.ruoyi.production.mapper.*; |
| | | import com.ruoyi.production.pojo.*; |
| | | import com.ruoyi.production.service.ProductWorkOrderService; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.io.InputStream; |
| | | import java.io.OutputStream; |
| | | import java.math.BigDecimal; |
| | | import java.math.RoundingMode; |
| | | import java.net.URLEncoder; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | | @Service |
| | | @Transactional(rollbackFor = Exception.class) |
| | |
| | | private ProductProcessRouteItemMapper productProcessRouteItemMapper; |
| | | @Autowired |
| | | private ProductionProductMainMapper productionProductMainMapper; |
| | | @Autowired |
| | | private ProductionProductOutputMapper productionProductOutputMapper; |
| | | |
| | | @Value("${file.temp-dir}") |
| | | private String tempDir; |
| | |
| | | |
| | | @Override |
| | | public List<ProductWorkOrderDto> getByProductOrderId(Long productOrderId) { |
| | | return productWorkOrdermapper.getByProductOrderId(productOrderId); |
| | | List<ProductWorkOrderDto> productWorkOrderDtos = productWorkOrdermapper.getByProductOrderId(productOrderId); |
| | | if (CollectionUtils.isNotEmpty(productWorkOrderDtos)) { |
| | | productWorkOrderDtos.forEach(productWorkOrderDto -> { |
| | | // 查询关联产出表数据 |
| | | List<ProductionProductMain> productionProductMains = productionProductMainMapper.selectList(Wrappers.<ProductionProductMain>lambdaQuery().eq(ProductionProductMain::getWorkOrderId, productWorkOrderDto.getId())); |
| | | BigDecimal scrapQty = BigDecimal.ZERO; |
| | | if (CollectionUtils.isNotEmpty(productionProductMains)) { |
| | | // 计算报废数量 |
| | | List<Long> mainIds = productionProductMains.stream().map(ProductionProductMain::getId).collect(Collectors.toList()); |
| | | List<ProductionProductOutput> productionProductOutputs = productionProductOutputMapper.selectList(Wrappers.<ProductionProductOutput>lambdaQuery().in(ProductionProductOutput::getProductMainId, mainIds)); |
| | | scrapQty = productionProductOutputs.stream().map(ProductionProductOutput::getScrapQty).reduce(BigDecimal.ZERO, BigDecimal::add); |
| | | } |
| | | if (productWorkOrderDto.getCompleteQuantity().compareTo(BigDecimal.ZERO) > 0) { |
| | | productWorkOrderDto.setScrapRate(scrapQty.divide(productWorkOrderDto.getCompleteQuantity(), 2, RoundingMode.HALF_UP)); |
| | | } else { |
| | | productWorkOrderDto.setScrapRate(scrapQty.multiply(BigDecimal.valueOf(100))); |
| | | } |
| | | productWorkOrderDto.setCompleteQty(productWorkOrderDto.getCompleteQuantity().subtract(scrapQty)); |
| | | }); |
| | | } |
| | | return productWorkOrderDtos; |
| | | } |
| | | |
| | | } |