You can have a factory on repeat and insert a set number of units that the factory will not repeat. Just hold ALT and then anything you alt-queue will be built once only.
You have a shieldbot factory and your queue only has 1 bandit on repeat. Hold alt and click dirtbag 10 times. The factory will finish the current bandit, build 10 dirtbags and start making bandits again.
If you know you want a set number of units but don't want have to turn repeat off, just use that. I'd be curious to know what you need a quota system for after that. I would also bet that unless you're willing to implement the concept yourself, nobody is likely to make it for you either. It's just so niche of an ask.
Alternatively, if your problem is that you split your metal income over too many projects, then look into build priority. Have specific cons/factories set to high to make sure certain things finish first, as metal income allows.
As for repairs, well, I don't know of a good solution either other than to have the retreat zone away from production and with a different set of caretakers. That or not using a retreat zone and instead making sure to have a hefty number of front line cons dedicated to either repair, or at least attack move. Cons on attack move will prioritize repairing units over reclaimimg, with the exception of jumpy cons who are dumb and like to chase combat units with slow beam instead of doing con things.
Future Wars and a few other mods have a morphed caretaker that can repair (but not build or assist build), so those can exist near a factory and be dedicated to repairing. It would be nice if base ZK had something like that, but in the meantime you're stuck with either making a retreat site out of range of production, or manually ordering your stuff to repair. You can use a repeat command on cons/caretakers to repair a zone that doesn't include the factory, then one that does and they will jump beteween assiting production and repairing. It is still flawed in the sense that so long as their current project is not done, they will keep assisting production no matter how many damaged units are in the repair zone.