Payment of GST on Works Contract

Sir, I am a Government electrical contractor, in the past 3 months back i have taken a contract of Rs.8.64 Lakh of Supplying & erection of pumping machinery for water supply purpose. In this contract, I have purchased Pumps, Motors, Cables, Control panels and starter by paying GST. I have paid GST of 12% for Pump & Motor and 18% for Cables, Control panels and starter. I have feed the details of the invoices of the above materials and had filed GSTR3B. Now I have completed the contract and has taken the bill from the Government department after deduction of 2% Income tax and 1% building & welfare cess. I am having the following questions. 1. I have taken the check amount of Rs.8.35 Lakh after all deductions, wheather I have to pay GST for the cheque amount what I have received, If yes then what about the GST which I have paid at the time of purchasing material such as pumps, motors, cables etc. 2. If we have to pay GST on the whole cheque amount, then in that case we are paying GST on Materials, Labour payment made and the margin what we are getting. If this is so then we only working without getting any profit. Hence in this regard, I request you to guide in the above matter and explain how to save GST without vilolating Government rules.