hi, thanks for post, phlegm for a year could be some serious disease, especially if fever, decay, loss of weight are present;
bronchitis, interstitial lung disease,
tuberculosis,
pneumonia, bronquiectasis, are examples of illnesses which cause long duration phlegm, with respect to pain, it is common in lung diseases pain with similar characteristics, but it is something to investigate could be necessary chest
x ray,
tomography or magnetic resonance, blood tests, to begin, anyway you have an disease to study, because every illness has a different treatment, and i recommend to visit your phisycian, he'll examine you and tell if you have secretions or any anomaly in medical physical exam.