Zend certified PHP/Magento developer

Magento 2 exclude a product from UPS shipping but not from flatrate

For Magento 2 we have created an attribute to exclude that product from shipping methods and that product that is excluded will have an individual shipping price on it.

For example, we have 2 products in cart A and B, the A product has that attribute set to yes and has individual shipping rate as $5 and product B has that attribute as NO.
On the checkout page, the shipping must be calculated as the sum of product A having individual price, and product B shipping should be calculated via UPS.

If anyone can help in achieving the above scenario.